问题
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