X-Git-Url: https://apps.delaporte.us/gitweb/matrix-chore-bot.git/blobdiff_plain/99f1517e1c2cd574b1969a79d5631769f789debb..c9a600f294a52bf535e1c60d16b1715623183a69:/matrix_chore_bot/db.py?ds=sidebyside diff --git a/matrix_chore_bot/db.py b/matrix_chore_bot/db.py index 140f0a6..a0eae22 100644 --- a/matrix_chore_bot/db.py +++ b/matrix_chore_bot/db.py @@ -13,9 +13,6 @@ DATE_FORMAT = '%Y-%m-%d' def today(): return dt.now().strftime(DATE_FORMAT) -DEFAULT_DB_FILE = os.path.join(os.environ.get('MATRIX_DATA_DIR', ''), 'chores.db') -DB_FILE = os.environ.get('MATRIX_CHORE_DB_FILE', DEFAULT_DB_FILE) - logger = logging.getLogger(__name__) logging.basicConfig(filename='chore.log', encoding='utf-8', level=logging.DEBUG) @@ -38,14 +35,14 @@ def get_chore(session, chore_id): return session.exec(cmd).first() class Data(): - def __init__(self, db_file=None): - - if not db_file: - db_file = DB_FILE + def __init__(self, db_file): self.file = db_file self.engine = self.get_engine() + def get_db_file(self): + return self.file + def get_engine(self): return create_engine(f"sqlite:///{self.file}")