On 29 Jul 2011, at 7:49am, Jonathan Little wrote:

> Specifically, that page says that locking_mode = EXCLUSIVE is useful if "The 
> application wants to prevent other processes from accessing the database 
> file." However, if I start up a SQLite shell, set the locking_mode to 
> exclusive, and perform an insert or other write operation (such that the 
> exclusive lock should be acquired and not released), I can still read the 
> file from other processes (e.g. I can copy it using a file manager UI).

An exclusive lock will be retained only long enough to write changes to the 
database files. And since SQLite is very fast at this, the files will be locked 
only for a short time.  If you want to keep the database file locked for a 
longer time, declare your transactions explicitly using

BEGIN EXCLUSIVE TRANSACTION
    do all reading and writing here for the set of changes
END TRANSACTION

for the time you want the database to be locked.

More than you need to know about locking can be found at

<http://www.sqlite.org/lang_transaction.html>
<http://www.sqlite.org/lockingv3.html>

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to