Few days ago I posted questions about sqlite multi threading on sqlite
mailing list. I could paste link to this thread but it is for members only.
So here is content, maybe it wil help you in some cases:


Hi,

I'm reading documentation about multi threading. I just want to be sure:
1. I can safely create another thread (with new handle / connection) in my
application and modify SAME database at the same time
2. I want use second connection in thread for importing while main thread
working "normally". By import I mean not backup, but importing documents
(CSV)
3. Can user modify table while another thread importing to it (in
transaction)? What are restrictions? What should I look out for?
4. Records inserted by second thread will be "visible" for first connection
after second thread commit transaction?

Regards

Answers:

> Hi,
>
> I'm reading documentation about multi threading. I just want to be sure:
> 1. I can safely create another thread (with new handle / connection) in my
> application and modify SAME database at the same time
>

Yes, as long as you don't take compile-time or run-time actions to make
SQLite single-threaded.  The default is to be multi-threaded.



> 2. I want use second connection in thread for importing while main thread
> working "normally". By import I mean not backup, but importing documents
> (CSV)
>

Yes.


> 3. Can user modify table while another thread importing to it (in
> transaction)? What are restrictions? What should I look out for?
>

Only one thread can be in a write transaction at a time.  If you have two
threads that need to write, they have to take turns.


> 4. Records inserted by second thread will be "visible" for first
connection
> after second thread commit transaction?
>

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

Reply via email to