Re: How to open an sqlite3 for reading without being blocked by process writing to it?

"Keith Medcalf" <[email protected]> Mon, 09 Mar 2020 19:14:11 -0600
Newsgroups gmane.comp.db.sqlite.general
Organization This Side Up
Message-ID <[email protected]>
On Monday, 9 March, 2020 18:18, Peng Yu <[email protected]> wrote:

>But I never experience the problem in my original email when I used
>python3's default sqlite3 module (WAL was not used). What is the
>difference between the default sqlite3 module and apsw? Thanks.

THe relevant difference is that the sqlite3 wrapper sets a default busy timeout of 5000 milliseconds when opening a connection, which you can change with the timeout parameter on the sqlite3.connect connection constructor.

APSW does not do anything behind your back, so if you want a non-zero busy_timeout you have to set one.

cn = apsw.Connection( ... )

cn.setbusytimeout(5000)
or
cn.cursor().execute('pragma busy_timeout=5000;')

-- 
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users