0
votes

Error:

c = dbConnection.execute("SELECT compid FROM " + tableToUse + " WHERE id = ?", id) sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 2 supplied.

When I do:

def getcompid (dbConnection, tableToUse, id):
    c = dbConnection.execute("SELECT compid FROM " + tableToUse + " WHERE id = ?", id)

manualcompid = [('8','from01'),('35','28')]
for manid in manualcompid:

    ERROR:
    foundid = getcompid (dbConnection, tableToUse, manid[0])

    OR SAME ERROR:

    r = str(manid[0])
    foundid = getcompid (dbConnection, tableToUse, r)


    THE BELOW IS FINE:
    foundid = getcompid (dbConnection, tableToUse, '8')

It seams to me r should be 'simple' string same as '8', and more manid[0] is a string already. Why error?

Why I have to use: foundid = getcompid (dbConnection, tableToUse, (manid[0],)) ?

1

1 Answers

1
votes

The bindings need to be in a list or tuple. Try this:

c = dbConnection.execute(
    "SELECT compid FROM " + tableToUse + " WHERE id = ?", [id])