On 9 Mar 2016, at 5:00am, Philippe Riand <phil at riand.com> wrote:

> 1- Is it safe to share a single connection between all these threads 
> (assuming serialized mode)?

In addition to Keith's excellent reply ...

Are you using _prepare(), _step(), _finalize() ?  If so then make sure you 
understand the interaction between two threads which are doing _step() at the 
same time.  Always finalize as soon as you can, and perhaps even put each 
SELECT inside a "BEGIN EXCLUSIVE" transaction.

Also, you should get no SQLite errors with concurrent access.  None.  Even if 
you manage to get rid of 99% of the ones you have now, if you have any at all 
you still have a fault in your code or setup.  And that can come back to bite 
you when your software is deployed.

A good debugging tactic here is to remove from your code everything designed to 
speed up or optimize SQLite.  This includes but is not limited to PRAGMAs. This 
often banishes errors and gives you a stable platform to test.  If it's fast 
enough, ship it.  "Fast enough" means "optimization is a waste of my time".

Simon.

Reply via email to