On 9 Oct 2015, at 1:29pm, sanhua.zh <sanhua.zh at foxmail.com> wrote:

> 2. multithread-reading-and-writing, not serial

It is not possible for two different operations, whether different threads or 
different processes, to write to a database at the same time.  No matter what 
system you use this just isn't possible.

To prove this to yourself, imagine that you had a table with a UNIQUE index, 
and that two threads/processes tried to write rows with the same key.  The 
correct way for the API to respond would be to allow one to write its row, and 
to return an error to the other.  This cannot happen if the system accepts both 
write requests at the same time.  Writing to a database /must/ be serial.

There is a work-around for this which involve writing new rows by appending the 
data to a text file (entirely outside SQL) and having another process read its 
way through the text file updating the database file.  Appending to a text file 
is faster than updating a SQLite database.  There are other work-arounds too.  
But they all involve writing new data to some place which is not the live 
database.

Simon.

Reply via email to