diff --git a/db_module/__init__.py b/db_module/__init__.py index 07408cf..919cd32 100644 --- a/db_module/__init__.py +++ b/db_module/__init__.py @@ -1,8 +1,16 @@ -from .db import get_db, create_connection_pool, close_connection_pool, start_healthcheck_thread +import logging +from .db import ( + close_connection_pool, + create_connection_pool, + get_db, + start_healthcheck_thread, +) + +logging.getLogger(__name__).addHandler(logging.NullHandler()) __all__ = [ - "get_db", - "create_connection_pool", "close_connection_pool", + "create_connection_pool", + "get_db", "start_healthcheck_thread", ] diff --git a/db_module/db.py b/db_module/db.py index fc5f9a5..0d4ffae 100644 --- a/db_module/db.py +++ b/db_module/db.py @@ -1,16 +1,17 @@ -from mysql.connector import pooling, Error -from mysql.connector.pooling import MySQLConnectionPool, MySQLConnection -import threading -from secret_manager import return_credentials +import logging import os +import threading import time -from simple_logger_handler import setup_logger -from typing import Generator +from collections.abc import Generator -db_username = return_credentials("/etc/secrets/db_username") -db_password = return_credentials("/etc/secrets/db_password") +from mysql.connector import Error, pooling +from mysql.connector.pooling import MySQLConnection, MySQLConnectionPool +from secret_manager import get_secret -logger = setup_logger(__name__) +db_username = get_secret("/etc/secrets/db_username") +db_password = get_secret("/etc/secrets/db_password") + +logger = logging.getLogger(__name__) MAX_RETRIES = 10 RETRY_DELAY = 5 diff --git a/pyproject.toml b/pyproject.toml index 1b4c8dc..d12a1f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,11 +5,7 @@ description = "Shared database module" readme = "README.md" requires-python = ">=3.10" authors = [{ name = "Florian Gänsejunge" }] -dependencies = [ - "simple-logger-handler", - "mysql-connector-python==9.4.0", - "lib-secret-manager" -] +dependencies = ["mysql-connector-python==9.4.0","lib-secret-manager"] [build-system] requires = ["setuptools>=61", "wheel"]