Read only access only for sqlite3 from multiple threads

北战南征 提交于 2019-12-10 14:29:10

问题


According to http://www.sqlite.org/threadsafe.html there are three different threading modes when working with sqlite: single-threaded, multi-threaded and serialized. When configured to serialized and multi-threaded modes, mutexes are used (depending on the mode they are used more or less) and in single-threaded mode mutexes are not used at all.

Assuming that the database will only be used for queries (read-only access) is it possible to use the single-threaded mode while still accessing it from different threads? Or there are global resources that need to be protected?

In addition, can the default ADO.NET adapter System.Data.Sqlite be used in the same manner?


回答1:


The SQLite library has many internal data structures that get changed even for a read-only database file (caches, compiled statements, result sets, etc.), so you must never access a single-threaded connection from multiple threads.

ADO.NET does not make any thread safety guarantees, so neither does System.Data.SQLite.



来源:https://stackoverflow.com/questions/13912489/read-only-access-only-for-sqlite3-from-multiple-threads

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