0

The following code gives me an error:

db = sqlite3.connect(dbfile)
cursor = db.cursor()
cursor.execute("SELECT gsr, {} FROM {} WHERE session_id=?".format(column,table),(id))

where column and table are strings and id is a number. I'm getting a ValueError: parameters are of unsupported type error.

Why does this happen?

machinery
  • 5,972
  • 12
  • 67
  • 118

1 Answers1

0

Remove ( an ) arround id :

db = sqlite3.connect(dbfile)
cursor = db.cursor()
cursor.execute("SELECT gsr, {} FROM {} WHERE session_id=?".format(column,table),id)

You want use an int id to set ? not a tuple (id)

or use named placeholders :

db = sqlite3.connect(dbfile)
cursor = db.cursor()
cursor.execute("SELECT gsr, {} FROM {} WHERE session_id=:id".format(column,table),{"id":id})
Indent
  • 4,675
  • 1
  • 19
  • 35