Name error SQL table python

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.id
insert** 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()
5 Replies
Percy
Percy•2mo ago
Project ID: 2e253b3c-55fc-46c6-806c-f9d32de29a88
Queen Valkyrie 🥭
Queen Valkyrie 🥭OP•2mo ago
2e253b3c-55fc-46c6-806c-f9d32de29a88
Brody
Brody•2mo ago
I'm really sorry but we can't provide coding help here
Queen Valkyrie 🥭
Queen Valkyrie 🥭OP•2mo ago
Well I don't believe it's a coding issue seeing it's checked about 20 times. But thank you.
Brody
Brody•2mo ago
yep this a coding question as it has no relation to railway
Want results from more Discord servers?
Add your server