diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-04-20 16:58:15 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-04-20 16:58:15 +0300 |
commit | e38615c9c64e592cbea31f04bea726f5745648f7 (patch) | |
tree | 1d1c48316a29a292dadfcd5c00e80eb028f2511d /src | |
parent | be3701c55807336b9145994e621680f384090cbf (diff) |
support config.db_path
Diffstat (limited to 'src')
-rw-r--r-- | src/home/database/sqlite.py | 14 |
1 files changed, 8 insertions, 6 deletions
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__) |