我正在尝试使用Python (传统型,2.7)和SQLite (3)编写一个book indexer。
代码可以归结为以下SQL语句序列:
'select count(*) from tag_dict' ()
/* [(30,)] */
'select count(*) from file_meta' ()
/* [(63613,)] */
'begin transaction' ()
'select id from archive where name=?' ('158326-158457.zip',)
/* [(20,)] */
'select id from file where name=? and archive=?' ('158328.fb2', 20)
/* [(122707,)] */
'delete from file_meta where file=?' (122707,)
'commit transaction' ()
# error: cannot commit - no transaction is active
隔离级别是“延迟”的(“独占”也不会更好)。
我尝试使用connection.commit()而不是cursor.execute('commit') --没有发生任何有用的事情。
当然,我已经搜索了stackoverflow和Net,但由于性能原因,我找到的答案是irrelevant.
< code >H115所有SQL执行都是通过单个函数完成的,该函数确保我一次只打开一个游标。
那么,这里的事务有什么问题呢?
如果我使用connection.commit() (注意:没有connection.begin方法!),那么我只是丢失了数据。
当然,我已经对数据库文件及其目录的文件权限进行了两次/triple/d检查。
https://stackoverflow.com/questions/9773200
复制相似问题