Hi SQLiteuser0000, is that really your name? - If so, bless your parents :)

Seriously though, it is quite legal (and also done mostly) to have several connections to a database. What you can't do is read data WHILE another thread is writing to it in serializable mode as you are using. The table has to be locked for writing else you have no clue in which state of update the data you are reading is. You can change a connection's serializable mode to read uncommitted data with the appropriate setting, see:
http://www.sqlite.org/pragma.html#pragma_read_uncommitted

Point is, you WILL get SQLITE_BUSY errors when it is busy writing, for which you can set a time-out to accommodate fast transactions still committing - see:
http://www.sqlite.org/pragma.html#pragma_busy_timeout
The OS or another system may also lock the file to return those errors, or a 
thread setting this:
PRAGMA locking_mode = 'Exclusive';

But if any of those locks last too long, it will still fail with SQLITE_BUSY.

SQLITE_LOCKED, on the other hand, should only be returned if the specific Table you are attempting to access is locked by a thread specifically, which is only possible to get in non-serialized mode - or so I thought. (I must be wrong about this one, anyone who knows this specifically would like to confirm or correct me please?)
Check the extended result code too, See:
http://www.sqlite.org/c3ref/c_abort_rollback.html
After enabling the extended API, as shown here: (Needing 3.3.8 or later)
http://www.sqlite.org/c3ref/extended_result_codes.html
- which will all tell you much more specific what went wrong.


I hope this shed some light on your problem.

Cheers,
Ryan


On 2013/11/21 23:10, sqliteuser0000 wrote:
Hi.
Is it legal to use multiple connections to a database when the db is in
serialized mode and wal is enabled. Additionally i would like to open the
connections and use them from several threads. I keep getting SQLITE_LOCKED
errors and cannot read from the db when a write transaction from another
connection is ongoing.

Regards



--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Using-multiple-connections-from-multiple-threads-SQLITE-LOCKED-tp72532.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

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

Reply via email to