summaryrefslogtreecommitdiffstats
path: root/plugin.py
diff options
context:
space:
mode:
authorPratyush Desai2021-12-04 17:14:49 +0530
committerPratyush Desai2021-12-04 17:14:49 +0530
commit8c1679382f3e4a5da01d54b473ecf61cad75bc41 (patch)
treecf91eb765bbe42bed217abc0d5d93b9424c9895c /plugin.py
parent70a6114456c1e568ebd2ea9f1749d36300c875e8 (diff)
downloaddoselogging-8c1679382f3e4a5da01d54b473ecf61cad75bc41.tar.gz
doselogging-8c1679382f3e4a5da01d54b473ecf61cad75bc41.tar.bz2
doselogging-8c1679382f3e4a5da01d54b473ecf61cad75bc41.zip
initial sqlite integrationsqlite
Diffstat (limited to 'plugin.py')
-rw-r--r--plugin.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/plugin.py b/plugin.py
index bdceed9..8c98926 100644
--- a/plugin.py
+++ b/plugin.py
@@ -38,12 +38,46 @@ except ImportError:
# without the i18n module
_ = lambda x: x
+import os
+import sqlite3
+
+class SqliteDoselogsDB(object):
+ def __init__(self, filename):
+ self.db = {}
+ self.filename = filename
+
+ def close(self):
+ self.db.close()
+
+ def _getDb(self):
+ filename = os.path.basename(self.__class__.__name__)
+ if filename in self.db:
+ return self.db[filename]
+ if os.path.exists(filename):
+ db = sqlite3.connect(filename, check_same_thread=False)
+ self.db[filename] = db
+ return db
+ db = sqlite3.connect(filename, check_same_thread=False)
+ self.db[filename] = db
+ cursor = db.cursor()
+ cursor.execute("""CREATE TABLE doselogs (
+ id INTEGER PRIMARY KEY,
+ username TEXT,
+ nick TEXT,
+ timezone TEXT,
+ amount TEXT,
+ drug TEXT,
+ roa TEXT,
+ timestamp TEXT
+ )
+
+ """)
+
class DoseLogs(callbacks.Plugin):
"""Log and annotate your doses"""
threaded = True
-
Class = DoseLogs