U
U
uprj2021-04-07 08:54:54
Python
uprj, 2021-04-07 08:54:54

ValueError: parameters are of unsupported type?

I need to pull the user's balance from the table

cursor.execute("SELECT balance FROM users WHERE id=?", plusid)

That is, you need a user balance with an id, which is stored in the plusid variable. I get an
error:
cursor.execute("SELECT balance FROM users WHERE id=?", plusid)
ValueError: parameters are of unsupported type

All other queries in sqlite3 work for me, but this one does not want to.
If I put the variable in brackets
cursor.execute("SELECT balance FROM users WHERE id=?", (plusid))

That gives the same error. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uprj, 2021-04-07
@uprj

I watched questions on sqlite on Habré, and there the person also substituted one value, but the problem was not with this. In general, I figured it out. You need to put the value in brackets and put a comma after it.

cursor.execute("SELECT balance FROM users WHERE id=?", (plusid,))

Then everything works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question