diff --git a/.gitignore b/.gitignore index e69de29..600d2d3 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file 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