Reading uncommitted changes from SQLite database

倖福魔咒の 提交于 2020-01-14 10:37:32

问题


I wrote an application (using Qt in C++) which inserts data into a SQLite database. Another application reads data from the same database, but I noticed that it is not possible to read uncommitted data. I would like instead to be able to read data even if it is not committed yet.

Reading the SQLite documentation I found the pragma read_uncommitted which, from what I understand, should be what I need. Problem is that, even if I set that to true, I cannot get uncommitted data.

I tried to run my application which performs the insertion process, and, at the same time, start the sqlite3 client. I set the pragma to true and I try to count the records inside the table. What I get is always 0 (database was empty before my insertion process started), until the entire process finishes where I immediately get the entire data.

Am I doing something wrong? Isn't this pragma supposed to make the sqlite3 client behave differently?


回答1:


I answer to myself: no, it seems it is not possible. The read_uncommitted isolation mode requires to enable the shared cache, which is possible currently only for different threads living in the same process. This seems the best place to study this: http://www.sqlite.org/sharedcache.html.



来源:https://stackoverflow.com/questions/7370947/reading-uncommitted-changes-from-sqlite-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!