T
T
timkin12018-07-28 23:57:22
MySQL
timkin1, 2018-07-28 23:57:22

Why does the Not all parameters were used in the SQL statement error occur?

Hello!
I'm trying to execute the following query to enter data into the database:

INSERT INTO users (chat_id, username, first_name, last_name) VALUES (?, ?, ?, ?)

And here in Python
ins = 'INSERT INTO users (chat_id, username, first_name, last_name) VALUES (?, ?, ?, ?)'
        user_bd.execute(ins, (message.chat.id, message.chat.username,
                              message.chat.first_name, message.chat.last_name))
        user_bd.close()
        connection.close()

In Telegram message.chat.id = int;
the rest are string.
The database looks like this:
5b5cd88a12531408722385.png
But for some reason, while the program is running, an error is generated Not all parameters were used in the SQL statement. Tell me, please, what is the reason for this?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex22b, 2020-07-02
@Alex22b

Try replacing question marks with %s helped me

A
Andy_U, 2018-07-29
@Andy_U

Try enclosing the tuple in square brackets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question