同一个sqlite数据库的不同连接可以同时开始事务吗? [英] Can different connections of the same sqlite's database begin transactions concurrently?

查看:36
本文介绍了同一个sqlite数据库的不同连接可以同时开始事务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个关于 sqlite3 的奇怪问题.我使用 open() 方法获得了同一数据库文件的不同连接.连接1开始一个事务,连接2开始另一个事务,就是更新一个表的几条记录.然后连接 1 提交事务,然后连接 2 提交其事务.但是我发现连接2的更新命令实际上从来没有更新数据库中的记录.在此过程中没有抛出异常.我不知道为什么会出现这个问题.谁能给我解释一下原因?

I met with a strange problem about sqlite3. I obtained different connections of the same database file using open() method. connection 1 begins a transaction, and connection 2 begins another transaction, which is to update several records of a table. Then connection 1 commit the transaction, followed by connection 2 commit its transaction. But I found that the update command of connection 2 is never actually update the record in the database. There is no exception throwed during this procedure. I don't know why the problem occurs. Can anyone explain the reason to me?

推荐答案

如果你阅读 SQLite 文档,你会看到它支持多连接只读,不能从多连接写入数据库,因为它不是设计的为此.

If you read the SQLite documentation, you will see that it supports multiple connections for reading only, you cannot write to the database from mulitple connections, because it's not designed for that.

http://www.sqlite.org/faq.html#q5

这篇关于同一个sqlite数据库的不同连接可以同时开始事务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆