2

I have been looking for answers and working on this for many hours. In the spatialite database table nodes, id is an integer.

    idValToNode = 854

    sql =  'UPDATE nodes SET obsolete = 0 WHERE id = ?'
    cur.execute(sql, idValToNode)

ValueError: parameters are of unsupported type

    idValToNode = 854

    sql =  'UPDATE nodes SET obsolete = 0 WHERE id = ?'
    cur.execute(sql, str(idValToNode))

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

    idValToNode = 854

    sql =  'UPDATE nodes SET obsolete = 0 WHERE id = ?'
    cur.execute(sql, idValToNode,)

ValueError: parameters are of unsupported type

If I place the 854 inside the sql statement and remove the variable, it works fine. I need to use a variable. Please help. What am I missing here?

1 Answer 1

3

Looking at the docs, your parameter needs to be a tuple, and Python expects single-element tuples to be constructed like this: (idValToNode,). That would make your cur.execute() function look more like this:

cur.execute(sql, (idValToNode,))
1
  • Adding the parenthesis worked great! Glad it was a simple solution. Much appreciated.
    – Terry
    Commented Jan 6, 2015 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.