mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-26 06:56:36 +00:00
Add tubesync.sqlite3
This commit is contained in:
parent
a11e3487d6
commit
658f690b5b
28
tubesync/tubesync/sqlite3/base.py
Normal file
28
tubesync/tubesync/sqlite3/base.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from django.db.backends.sqlite3 import base
|
||||||
|
|
||||||
|
|
||||||
|
class DatabaseWrapper(base.DatabaseWrapper):
|
||||||
|
|
||||||
|
def _start_transaction_under_autocommit(self):
|
||||||
|
conn_params = self.get_connection_params()
|
||||||
|
if "transaction_mode" not in conn_params:
|
||||||
|
self.cursor().execute("BEGIN TRANSACTION")
|
||||||
|
else:
|
||||||
|
tm = str(conn_params["transaction_mode"]).upper().strip()
|
||||||
|
transaction_modes = frozenset(["DEFERRED", "EXCLUSIVE", "IMMEDIATE"])
|
||||||
|
if tm in transaction_modes:
|
||||||
|
self.cursor().execute(f"BEGIN {tm} TRANSACTION")
|
||||||
|
else:
|
||||||
|
self.cursor().execute("BEGIN TRANSACTION")
|
||||||
|
|
||||||
|
|
||||||
|
def init_connection_state(self):
|
||||||
|
conn_params = self.get_connection_params()
|
||||||
|
if "init_command" in conn_params:
|
||||||
|
ic = str(conn_params["init_command"])
|
||||||
|
cmds = ic.split(';')
|
||||||
|
with self.cursor() as cursor:
|
||||||
|
for init_cmd in cmds:
|
||||||
|
cursor.execute(init_cmd.strip())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user