jno*_*jno 16 python sqlite transactions commit
我正在尝试使用Python(传统的,2.7)和SQLite(3)来编写书籍索引器.
代码归结为这一系列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
Run Code Online (Sandbox Code Playgroud)
隔离级别为"DEFERRED"("EXCLUSIVE"并不是更好).
我试图使用connection.commit()而不是cursor.execute('commit') - 没有任何用处.
如果我使用connection.commit()(注意:没有connection.begin方法!),那么我只是松开了我的数据.
当然,我已经对数据库文件及其目录中的doube/triple/quaruple检查了文件权限.
好吧,正如经常发生的那样,我在提出问题后几分钟就找到了解决方案.
作为一个新手,我不能在8个小时内回答我自己的问题......所以,现在的答案是:
解决方案在这里找到并且包含唯一的想法:
这听起来很奇怪,但它确实有效.
| 归档时间: |
|
| 查看次数: |
14287 次 |
| 最近记录: |