Multi-Threaded SQLite Without the OperationalErrors
Until that transaction commits or is rolled back, no other connection can write to the database (in older versions of SQLite, it used to be the case that readers were blocked, too, but thanks to the addition of write-ahead logging, readers can co-exist with the writer and vice-versa). The object has a method, which is called by the writer thread when results are ready, and a corresponding method which is used behind-the-scenes to block the caller while the query is in-flight. Because all write queries are executed using the same connection, and because the write queries may arrive in the queue out-of-order (when multiple threads are issuing writes at the same time), it is impossible to predict how a multi-statement transaction would play out.
Source: charlesleifer.com