Deboparna :
My code:
cursor.execute("select * from PRODUCT where product_id in (?)", (ids,))
print(cursor.fetchall())
where ids
is a tuple of integer values like (2,4)
and product_id
are also integer values.
The error I'm getting is:
File "c:/Users/deboparna/Desktop/college/Sem4/programming language/project/db.py", line 32, in fetchProducts cursor.execute("select * from PRODUCT where product_id in (?)", (ids,)) sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
Vorsprung durch Technik :
You need placeholders for each id.
You also should just use ids
as a tuple, and not make it a tuple of a tuple.
placeholders = ",".join("?"*len(ids))
qry = "select * from product where product_id in ({})".format(placeholders)
cursor.execute(qry,ids)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=293571&siteId=1