2013-11-26 82 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,))