From e38615c9c64e592cbea31f04bea726f5745648f7 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Thu, 20 Apr 2023 16:58:15 +0300 Subject: support config.db_path --- src/home/database/sqlite.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/home/database/sqlite.py b/src/home/database/sqlite.py index a3a1664..bfba929 100644 --- a/src/home/database/sqlite.py +++ b/src/home/database/sqlite.py @@ -13,14 +13,16 @@ class SQLiteBase: SCHEMA = 1 def __init__(self, name=None, dbname='bot', check_same_thread=False): - if not name: - name = config.app_name - if not dbname: - dbname = name + db_path = config.get('db_path', default=None) + if db_path is None: + if not name: + name = config.app_name + if not dbname: + dbname = name + db_path = _get_database_path(name, dbname) self.logger = logging.getLogger(self.__class__.__name__) - self.sqlite = sqlite3.connect(_get_database_path(name, dbname), - check_same_thread=check_same_thread) + self.sqlite = sqlite3.connect(db_path, check_same_thread=check_same_thread) if is_development_mode(): self.sql_logger = logging.getLogger(self.__class__.__name__) -- cgit v1.2.3