Mercurial > libervia-backend
comparison libervia/backend/memory/sqla_config.py @ 4071:4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 11:49:51 +0200 |
parents | sat/memory/sqla_config.py@524856bd7b19 |
children |
comparison
equal
deleted
inserted
replaced
4070:d10748475025 | 4071:4b842c1fb686 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 # Libervia: an XMPP client | |
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) | |
5 | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 from pathlib import Path | |
20 from urllib.parse import quote | |
21 from libervia.backend.core.constants import Const as C | |
22 from libervia.backend.tools import config | |
23 | |
24 | |
25 def get_db_config() -> dict: | |
26 """Get configuration for database | |
27 | |
28 @return: dict with following keys: | |
29 - type: only "sqlite" for now | |
30 - path: path to the sqlite DB | |
31 """ | |
32 main_conf = config.parse_main_conf() | |
33 local_dir = Path(config.config_get(main_conf, "", "local_dir")) | |
34 database_path = (local_dir / C.SAVEFILE_DATABASE).expanduser() | |
35 url = f"sqlite+aiosqlite:///{quote(str(database_path))}?timeout=30" | |
36 return { | |
37 "type": "sqlite", | |
38 "path": database_path, | |
39 "url": url, | |
40 } |