2 years ago
I'm encountering a NameError indicating that guild_id is not defined during the insertion process.
I have the following code for creating the schedules table:
cursor.execute('''
CREATE TABLE IF NOT EXISTS schedules (
guild_id BIGINT PRIMARY KEY,
channel_id BIGINT NOT NULL,
hour INT NOT NULL,
minute INT NOT NULL,
timezone VARCHAR(50) NOT NULL,
frequency ENUM('daily', '2-daily', 'weekly') NOT NULL
)
''')
A
**and this for the callback:*(
async def schedule_callback(interaction, frequency, hour, minute, timezone):
await interaction.response.defer()
ctx = interaction.channel
guild_id = interaction.guild.idinsert
connection = create_connection()
cursor = connection.cursor()
cursor.execute('''
INSERT INTO schedules (guild_id, channel_id, hour, minute, timezone, frequency)
VALUES (%s, %s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
guild_id = VALUES(guild_id), # Adding guild_id here
channel_id = VALUES(channel_id),
hour = VALUES(hour),
minute = VALUES(minute),
timezone = VALUES(timezone),
frequency = VALUES(frequency)
''', (guild_id, channel_id, hour, minute, timezone, frequency))
connection.commit()
cursor.close()
connection.close()
4 Replies
2 years ago
I'm really sorry but we can't provide coding help here
Well I don't believe it's a coding issue seeing it's checked about 20 times.
But thank you.
2 years ago
yep this a coding question as it has no relation to railway