asyncpg.exceptions.PostgresSyntaxError: INSERT has more expressions than target columns

Viewed 10

This is my code where i get error for

async def get_prefix(bot, message):
    if not message.guild:
        return commands.when_mentioned(DEFAULT_PREFIX)(bot, message)

    prefix = await client.db.fetch('SELECT prefix FROM guilds WHERE "guild_id" = $1', message.guild.id)
    if len(prefix) == 0:
        await client.db.execute('INSERT INTO guilds(guild_id) VALUES ($1, $2)', message.guild.id, DEFAULT_PREFIX)
        prefix = DEFAULT_PREFIX
    else:
        prefix = prefix[0].get("prefix")
    return commands.when_mentioned_or(prefix)(bot,message)

And this is the error

File "asyncpg\protocol\protocol.pyx", line 168, in prepare asyncpg.exceptions.PostgresSyntaxError: INSERT has more expressions than target columns

How can i fix this?

0 Answers
Related