0

I am trying to execute following python code:

  conn = sqlite3.connect("db")
conn.row_factory = sqlite3.Row
cursor = conn.cursor()

    change_list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "ka", "ko"]
    for change in change_list:
        rows = cursor.execute("select * from determine_image where modification_type = ?", (change)).fetchall()
        for row in rows:
            print (row)

but all I get is the following error:

sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 12 supplied.

I do not understand why I get that error, would you kindly tell me why I am getting this error and how to solve it?

I am using python 2.7 and sqlite3

mark
  • 351
  • 1
  • 3
  • 16
  • `(change)` is not a tuple, that's just a grouped expression and exactly the same thing as `change`. You need a *comma*: `(change,)`, or make it a list: `[change]`. See the duplicate. – Martijn Pieters Feb 24 '19 at 21:37
  • Note: for future reference, you want to make sure your sample code still produces that exact error. Beacuse *in this case* it doesn't actually produce that error beacuse each of your `change` values is a string with a single character, so an iterable with **one** element, and your code actually *works fine*. Your actual code has 12 characters in one of the `change_list` strings. – Martijn Pieters Feb 24 '19 at 21:38

0 Answers0