Python sqlite3.ProgrammingError:提供的绑定数量不正确。当前语句使用1,提供了2754个
表格Python sqlite3.ProgrammingError:提供的绑定数量不正确。当前语句使用1,提供了2754个,python,sqlite,Python,Sqlite,表格 c.execute("CREATE TABLE project ( id INTEGER PRIMARY KEY AUTOINCREMENT, content TEXT, postdate TIMESTAMP NOT NULL default CURRENT_TIMESTAMP) ") te = "testing" c.execute("INSERT INTO project (content) values (?)", (te)) 错误 sqlite3.Pro
c.execute("CREATE TABLE project (
id INTEGER PRIMARY KEY AUTOINCREMENT,
content TEXT,
postdate TIMESTAMP NOT NULL default CURRENT_TIMESTAMP)
")
te = "testing"
c.execute("INSERT INTO project (content) values (?)", (te))
错误
sqlite3.ProgrammingError: Incorrect number of bindings supplied.
The current statement uses 1, and there are 7 supplied.
尝试将其更改为:
c.execute("INSERT INTO project (content) values (?)", (te,))
(在te后面加逗号)。这是因为不带逗号的
(te)
不是元组,必须在元组中传递参数。如果只有一个元素,则必须通过插入最后一个逗号来告诉python它是一个元组。它是哪一个?是否提供了2754个或7个?为什么标题和问题之间的错误消息不同?或者将其更改为列表。