summaryrefslogtreecommitdiff
path: root/src/home/database/sqlite.py
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-11-18 04:11:14 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-11-18 04:11:14 +0300
commit7d2f2a89ac7030dc3e13de735048b267c1b390b8 (patch)
tree20e2ca42d3b3f95f746e63c529a741eee6244aff /src/home/database/sqlite.py
parentbbf71ac894b3f155fbc0e74d1d17a121c68e4cc5 (diff)
sound_sensor_server: persistent guard_enabled state
Diffstat (limited to 'src/home/database/sqlite.py')
-rw-r--r--src/home/database/sqlite.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/home/database/sqlite.py b/src/home/database/sqlite.py
index 8f1763e..a3a1664 100644
--- a/src/home/database/sqlite.py
+++ b/src/home/database/sqlite.py
@@ -5,19 +5,21 @@ import logging
from ..config import config, is_development_mode
-def _get_database_path(name) -> str:
- return os.path.join(os.environ['HOME'], '.config', name, 'bot.db')
+def _get_database_path(name: str, dbname: str) -> str:
+ return os.path.join(os.environ['HOME'], '.config', name, f'{dbname}.db')
class SQLiteBase:
SCHEMA = 1
- def __init__(self, name=None, check_same_thread=False):
+ def __init__(self, name=None, dbname='bot', check_same_thread=False):
if not name:
name = config.app_name
+ if not dbname:
+ dbname = name
self.logger = logging.getLogger(self.__class__.__name__)
- self.sqlite = sqlite3.connect(_get_database_path(name),
+ self.sqlite = sqlite3.connect(_get_database_path(name, dbname),
check_same_thread=check_same_thread)
if is_development_mode():