【发布时间】:2021-08-19 05:41:10
【问题描述】:
我有一个执行一些简单 SQL 的 python 脚本。
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()
但是当我执行它时,我得到一个错误
sqlite3.OperationalError: 表 simpletable 有 5 列但提供了 4 个值
为什么不自动填写id键?
【问题讨论】: