同一个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