summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-04-20 16:58:15 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-04-20 16:58:15 +0300
commite38615c9c64e592cbea31f04bea726f5745648f7 (patch)
tree1d1c48316a29a292dadfcd5c00e80eb028f2511d
parentbe3701c55807336b9145994e621680f384090cbf (diff)
support config.db_path
-rw-r--r--doc/ipcam_server.md2
-rw-r--r--src/home/database/sqlite.py14
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__)