2013-11-26 51 views
6

我试图在我的数据库的行条目中插入一个None值。表present存在在Python中插入Null到SQLite3中

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

,但我得到的错误:

ValueError: parameters are of unsupported type 

我怎么插入的行中的第二个字段为空值?

+0

你尝试用NULL? – opalenzuela

回答

17

使用一个元组,即:

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