我正在尝试从代码将新记录插入SQLite
数据库。Python
con = sqlite.connect(connectionString)
cur = con.cursor()
countOfNewItems = 0
for ...
try:
con.execute("insert or ignore into items ...")
countOfNewItems += cur.rowcount
except:
cur.close()
con.close()
print "Error when inserting item '%s' to database." % item
exit(1)
cur.close()
con.commit()
con.close()
print "%d new items have been inserted." % countOfNewItems
我的代码报告了负数的插入记录(-5141)。
因为我的数据库是空的,所以我可以通过命令行查看插入了多少条记录
select count(*) from items;
4866
你能告诉我有什么问题吗?为什么这两个值不匹配,为什么它是负数?