Revize b593b83c
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
src/config/connection_provider.py | ||
---|---|---|
9 | 9 |
|
10 | 10 |
|
11 | 11 |
class ConnectionProvider(Module): |
12 |
""" |
|
13 |
Dependency injection module that provides database connection singleton |
|
14 |
""" |
|
12 | 15 |
|
13 | 16 |
@singleton |
14 | 17 |
@provider |
15 | 18 |
def connect(self, configuration: Configuration) -> Connection: |
19 |
""" |
|
20 |
Create an SQLite connection based on the given configuration |
|
21 |
:param configuration: Configuration class with application config data |
|
22 |
:return: connection singleton |
|
23 |
""" |
|
16 | 24 |
co = sqlite3.connect(database=configuration.connection_string, check_same_thread=False) |
17 | 25 |
cu = co.cursor() |
18 | 26 |
cu.executescript(SCHEMA_SQL) # TODO change setup_database not to drop tables if they exist |
Také k dispozici: Unified diff
Re #8569 Added comments to connection_provider.py