On 5/4/2012 1:52 PM, KUSHAL SHAH wrote:
I am trying to use SQLite in my .NET project. Client APIs are from 
System.Data.SqLite. Can you please help with below:

It seemsthat multiple
threads can actually read simultaneously from a sqlite Db. However, I am
confused about the write part. Will SQLite manage the write requests or the
user has to have specific flags/locks on the connection?

Every connection has an associated mutex, and every SQLite API function calls are synchronized on this mutex.

I couldn’t find good documentation around it.

http://sqlite.org/threadsafe.html

Specifically, I am looking for the
following scenarios:

1.       I am reading Db and on another thread is
writing to that Db. Do I need specific flags on each of the connections? If so,
which ones?

Ah, so it's two separate connections? Earlier, you were talking about "the" connection. With multiple connections, different rules apply:

http://sqlite.org/lockingv3.html
http://sqlite.org/wal.html

Unless you enable WAL mode, you won't be able to read on one connection and write on another simultaneously.

2.       Both threads want to write to the Db? What
flags/locks can I have in my code to achieve that, if at all?

You can't have two writing connections, even in WAL mode. The two threads may share the same connection, but then they would be effectively serialized anyway, so you won't get any benefit from having two of them.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to