首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python/SQLite3:无法提交-没有活动的事务

Python/SQLite3:无法提交-没有活动的事务
EN

Stack Overflow用户
提问于 2012-03-19 23:41:24
回答 3查看 19.9K关注 0票数 19

我正在尝试使用Python (传统型,2.7)和SQLite (3)编写一个book indexer

代码可以归结为以下SQL语句序列:

代码语言:javascript
复制
'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.

  • Autocommit is
  • 我一次使用唯一的数据库文件。
  • 我的代码在单线程中运行。

< code >H115所有SQL执行都是通过单个函数完成的,该函数确保我一次只打开一个游标。

那么,这里的事务有什么问题呢?

如果我使用connection.commit() (注意:没有connection.begin方法!),那么我只是丢失了数据。

当然,我已经对数据库文件及其目录的文件权限进行了两次/triple/d检查。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9773200

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档