lundi 30 novembre 2015

How to set SQLite isolation levels, using Python

I know (or at least, I think that I know), that in standard there are four isolation levels when dealing with transactions:

READ UNCOMMITTED - will allow everything
READ COMMITTED - will not allow dirty reads 
REPEATABLE READ - will not allow dirty, non-repearable reads   
SERIALIZABLE - will not allow dirty, non-repearable, phantom reads

I know that and, for example, when dealing with MySQL I can do something like:

cursor = db.cursor()
cursor.execute("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED")

Or, if I'm dealing with Postgre, I can do something like:

db.set_isolation_level(3) # corresponds to SERIALIZABLE

So, I wonder, if I can do something similar to that when dealing with SQLite. I've only seen:

db.isolation_level = None

but I'm not sure what it means and how I can set other isolation levels (if they exist in the context of SQLite). Thanks!

Aucun commentaire:

Enregistrer un commentaire