Insert Null into SQLite3 in Python

moesef picture moesef · Nov 26, 2013 · Viewed 19.8k times · Source

I am trying to insert a None value into a row entry of my db. The table present exists

db.execute("INSERT INTO present VALUES('test', ?, 9)", "This is a test!")
db.execute("INSERT INTO present VALUES('test2', ?, 10)", None)

but I get an error:

ValueError: parameters are of unsupported type

how do I insert a blank value for the second field in the row?

Answer

Tim Wilder picture Tim Wilder · Nov 26, 2013

Use a tuple, I.E.:

db.execute("INSERT INTO present VALUES('test2', ?, 10)", (None,))