summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorMichaël Ball <michael.ball@gmail.com>2014-12-13 16:41:35 +0000
committerMichaël Ball <michael.ball@gmail.com>2014-12-13 16:41:35 +0000
commitcd630834a985be4b39a673d022e180de3ff20517 (patch)
tree0cfdcba2570ca7925e3777104448e83501fa328c /db
parent86e68485b0848e25ef6d5b579c7d80f286d094a1 (diff)
Initial commit
Diffstat (limited to 'db')
-rw-r--r--db/__init__.py0
-rw-r--r--db/db_manager.py54
2 files changed, 54 insertions, 0 deletions
diff --git a/db/__init__.py b/db/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/db/__init__.py
diff --git a/db/db_manager.py b/db/db_manager.py
new file mode 100644
index 0000000..44d6b96
--- /dev/null
+++ b/db/db_manager.py
@@ -0,0 +1,54 @@
+import configparser
+import sqlite3
+
+
+class DbManager:
+ class __DbManager:
+ def __init__(self):
+ config = configparser.ConfigParser()
+ config.read("mach2.ini")
+ self.conn = sqlite3.connect(config["DEFAULT"]["database"])
+
+ def __str__(self):
+ return repr(self)
+
+ def execute(self, *args):
+ return self.conn.execute(*args)
+
+ def cursor(self):
+ return self.conn.cursor()
+
+ def commit(self):
+ return self.conn.commit()
+
+ def close(self):
+ return self.conn.close()
+
+ def rollback(self):
+ return self.conn.rollback()
+
+ def executemany(self, *args):
+ return self.conn.executemany(*args)
+
+ def executescript(self, *args):
+ return self.conn.executescript(*args)
+
+ def create_function(self, *args):
+ return self.conn.create_function(*args)
+
+ def create_aggregate(self, *args):
+ return self.conn.create_aggregate(*args)
+
+ def create_collation(self, *args):
+ return self.conn.create_collation(*args)
+
+ def interrupt(self):
+ return self.conn.interrupt()
+
+ instance = None
+
+ def __new__(cls):
+ if not DbManager.instance:
+ DbManager.instance = DbManager.__DbManager()
+
+ return DbManager.instance