Jac*_*ian 6 python sqlite 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
Run Code Online (Sandbox Code Playgroud)
我知道这一点,例如,在与MySQL
我打交道时,我可以执行以下操作:
cursor = db.cursor()
cursor.execute("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED")
Run Code Online (Sandbox Code Playgroud)
或者,如果我正在处理 Postgre,我可以执行以下操作:
db.set_isolation_level(3) # corresponds to SERIALIZABLE
Run Code Online (Sandbox Code Playgroud)
所以,我想知道,在处理SQLite
. 我只看过:
db.isolation_level = None
Run Code Online (Sandbox Code Playgroud)
但我不确定这意味着什么以及如何设置其他隔离级别(如果它们存在于 的上下文中SQLite
)。谢谢!
There are PRAGMA statements in sqlite. It seems you can do this:
db.execute("PRAGMA read_uncommitted = true;");
Run Code Online (Sandbox Code Playgroud)