/
base.py
20 lines (16 loc) · 843 Bytes
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# from django.db.backends.sqlite3.base import *
from django.db.backends.sqlite3.base import DatabaseWrapper as Sqlite3DatabaseWrapper
from concurrency.db.backends.common import TriggerMixin
from concurrency.db.backends.sqlite3.creation import Sqlite3Creation
class DatabaseWrapper(TriggerMixin, Sqlite3DatabaseWrapper):
def __init__(self, *args, **kwargs):
super(DatabaseWrapper, self).__init__(*args, **kwargs)
self.creation = Sqlite3Creation(self)
def list_triggers(self):
cursor = self.cursor()
result = cursor.execute("select name from sqlite_master where type='trigger';")
return [m[0] for m in result.fetchall()]
def drop_trigger(self, trigger_name):
cursor = self.cursor()
result = cursor.execute("DROP TRIGGER IF EXISTS %s;" % trigger_name)
return result