I am trying to query my sqlite3 db and use values from a list. Here's my code:
for i in range(len(infolist)):
result = cursor.execute('SELECT COUNT(DISTINCT col1)
FROM tablename
WHERE col2 = ?', (infolist[i]))
I receive this error:
ProgrammingError: 'Incorrect number of bindings supplied. The current statement uses 1, and there are 22 supplied.'
The string has 22 characters which explains why there are 22 bindings. Clearly I'm not passing the string correctly into the SQL statement.
INclause, if the array can be turned into a comma separated list, would work better & alleviate the need for the loop.