相关疑难解决方法(0)

SQLite 与 Python“表有 X 列,但提供了 Y”

我有一个 python 脚本,可以执行一些简单的 SQL。

c.execute("CREATE TABLE IF NOT EXISTS simpletable (id integer PRIMARY KEY, post_body text, post_id text, comment_id text, url text);")
command = "INSERT OR IGNORE INTO simpletable VALUES ('%s', '%s', '%s', '%s')" % (comments[-1].post_body, comments[-1].post_id, comments[-1].comment_id, 
comments[-1].url)
c.execute(command)
c.commit()
Run Code Online (Sandbox Code Playgroud)

但是当我执行它时,我收到错误

sqlite3.OperationalError:表 simpletable 有 5 列,但提供了 4 个值

为什么它不自动填写密钥id

python sql sqlite

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×1

sql ×1

sqlite ×1