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 --- doc/ipcam_server.md | 2 +- src/home/database/sqlite.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/ipcam_server.md b/doc/ipcam_server.md index 487e527..2c5ac40 100644 --- a/doc/ipcam_server.md +++ b/doc/ipcam_server.md @@ -56,4 +56,4 @@ cleanup_interval: 86400 ## Usage -Use provided systemd unit file. \ No newline at end of file +Use provided systemd unit file. 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