Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why do I get "sqlite3.ProgrammingError: Incorrect number of bindings supplied." even though I used a tuple?

I’m working on a Discord bot and don’t understand why I’m getting the error sqlite3.ProgrammingError: Incorrect number of bindings supplied.. The data in the database is [('123', 'hello world!'), ('111', 'testing lolz')] and when I run the command ‘search’ with ‘123’ as the id the bot should reply with ‘hello world!’. I’ve seen this post and as the answer says, I used a tuple in the Sqlite3 code. Here is the code for the ‘search’ command:

@tree.command(name='search', description='search for a message by id!', guild=discord.Object(id=1025197159785693284))
async def search(intr: discord.Interaction, id: str):
    res = cur.execute('SELECT message FROM messages WHERE id="(?)"', (id, )).fetchone()
    await intr.response.send_message(f'message {id} is: {res[0]}')

    con.commit()

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Try this:

res = cur.execute('SELECT message FROM messages WHERE id=(?)', (id, )).fetchone()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading