Compare commits

...

1 Commits

Author SHA1 Message Date
8c1679382f
initial sqlite integration 2021-12-04 17:14:49 +05:30
2 changed files with 36 additions and 1 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
.vscode

View File

@ -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