A few weeks ago, I posted this question on SO regarding how to lock a sqlite3 database in python:
How to lock a sqlite3 database in Python?
However, I\'m not
'with con' is NOT what is wanted here. (or this thread locking rubbish)
To get exclusive access for a specific period (not just while an individual query/trasaction is taking place) you need to do;
con = sqlite3.connect()
con.isolation_level = 'EXCLUSIVE'
con.execute('BEGIN EXCLUSIVE')
#exclusive access starts here. Nothing else can r/w the db, do your magic here.
con.commit()
con.close()
Hopefully this saves someone from the searching/experimenting i've just been through!
Remember it's not exclusive until you run begin exclusive, and it will stay exclusive until you close (or run commit, i think). You can always test w/ the python interpreter / CL sqlite3 app if you aren't sure.