[Tutor] SQLite database locked problem

Christian Witts cwitts at compuscan.co.za
Tue Jul 20 07:28:45 CEST 2010

On 20/07/2010 06:48, Che M wrote:
> I'm using an SQLite3 database (with Python 2.5) and every so often the 
> application crashes or hangs because somewhere there is this error, or 
> something like it:
> OperationalError:  database is locked.
> This is probably because I am viewing and sometimes changing the 
> database through SQLite Database Browser while working on my app, and 
> occasionally the app tries to access the db when the Database Browser 
> is writing to it or something like that.
> I'd like to a) know how to reproduce the error (haven't seen it in a 
> while, but want to be sure  know when it may happen for users and b) 
> prevent it from being a problem in the running app.
> Any suggestions welcome.  Thank you,
> Che
> ------------------------------------------------------------------------
> Hotmail is redefining busy with tools for the New Busy. Get more from 
> your inbox. See how. 
> <http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

SQLite is technically thread safe, but a write operation locks the 
entire database [1]:
- Any resultset being step()'d through uses a shared read-only lock.
- Any insert/update being executed requires an exclusive write lock.

[1] http://www.sqlite.org/lockingv3.html

Kind Regards,
Christian Witts

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100720/858c974d/attachment.html>

More information about the Tutor mailing list