表格
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.
答案 0 :(得分:4)
尝试将其更改为:
c.execute("INSERT INTO project (content) values (?)", (te,))
(te后面的逗号)。这是因为没有逗号的(te)
不是元组,你必须在元组中传递参数。如果你只有一个元素,你必须通过插入一个最后的逗号来告诉python它是一个元组。