Vorbereitung Release 0.2.0
This commit is contained in:
@@ -4,15 +4,21 @@ Setup database connections
|
||||
import sqlite3
|
||||
import psycopg2
|
||||
import logging.config
|
||||
from platformdirs import PlatformDirs
|
||||
import sqlite3
|
||||
from logging import Logger
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
import psycopg2
|
||||
import requests
|
||||
import yaml
|
||||
from platformdirs import PlatformDirs
|
||||
|
||||
|
||||
def get_database_cursors(log, config: str):
|
||||
dirs = PlatformDirs(config)
|
||||
database_config = Path(dirs.user_config_dir, 'database-config.yaml')
|
||||
with open(database_config, 'rt') as f:
|
||||
database_config = Path(dirs.user_config_dir, "database-config.yaml")
|
||||
with open(database_config, "rt") as f:
|
||||
db_config = yaml.safe_load(f.read())
|
||||
sqlite_db = db_config["sqlite"]["file"]
|
||||
log.info('using SQLite3 database {}'.format(sqlite_db))
|
||||
@@ -23,10 +29,10 @@ def get_database_cursors(log, config: str):
|
||||
|
||||
|
||||
def create_tables(sqlite_conn, logger, recreate_db, scripts):
|
||||
logger.info('create_tables')
|
||||
logger.info("create_tables")
|
||||
for table_id in scripts:
|
||||
create_statement = scripts[table_id]['create']
|
||||
drop_statement = scripts[table_id]['drop']
|
||||
create_statement = scripts[table_id]["create"]
|
||||
drop_statement = scripts[table_id]["drop"]
|
||||
logger.debug(create_statement)
|
||||
cursor = sqlite_conn.cursor()
|
||||
if recreate_db:
|
||||
@@ -37,11 +43,12 @@ def create_tables(sqlite_conn, logger, recreate_db, scripts):
|
||||
|
||||
def get_logger(level, config: str):
|
||||
dirs = PlatformDirs(config)
|
||||
logging_config = Path(dirs.user_config_dir, 'logging-config.yaml')
|
||||
with open(logging_config, 'rt') as f:
|
||||
logging_config = Path(dirs.user_config_dir, "logging-config.yaml")
|
||||
log_config = None
|
||||
with open(logging_config, "rt") as f:
|
||||
log_config = yaml.safe_load(f.read())
|
||||
logging.config.dictConfig(log_config)
|
||||
logger = logging.getLogger('development')
|
||||
logger = logging.getLogger("development")
|
||||
if level is not None:
|
||||
match level:
|
||||
case 0:
|
||||
|
||||
Reference in New Issue
Block a user