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
何が悪いのか教えていただけますか。2 つの値が一致しないのはなぜですか。また、負の値になるのはなぜですか?