Reputation:
await self.client.db.execute('INSERT INTO config (watcher_channel) VALUES ($1) WHERE guild_id = $2', channel.id, ctx.guild.id)
Im using asyncpg
, idk why it gives me syntax error.
Error:
Command raised an exception: PostgresSyntaxError: syntax error at or near "WHERE"
Upvotes: 1
Views: 95
Reputation: 1270623
I am guessing you really want an update
:
update config
set watcher_channel = $1
where guild_id = $2;
INSERT
inserts a complete new row into the table. I suspect that you simply want to update a value in an existing row.
Upvotes: 0
Reputation: 522292
Rephrase your insert as INSERT INTO ... SELECT
:
await self.client.db.execute(
'INSERT INTO config (watcher_channel) SELECT $1 WHERE guild_id = $2',
channel.id, ctx.guild.id)
Upvotes: 1