db.py

Code Hygiene Score: 99

Issues 1

Zeile Typ Beschreibung
7 magic_number Magic Number gefunden: 100

Dependencies 2

Funktionen 2

Code

"""DB-Wrapper für mcp-code - nutzt Shared Infrastructure."""

from config import Config
from shared.infrastructure import SimpleDbConnection


def execute_query(query: str, params: tuple = None, max_rows: int = 100) -> list:
    """Fuehrt Query aus und gibt Ergebnisse zurueck."""
    with SimpleDbConnection.get_connection(Config) as conn:
        with conn.cursor() as cursor:
            cursor.execute(query, params or ())
            return cursor.fetchmany(max_rows)


def execute_single(query: str, params: tuple = None) -> dict | None:
    """Fuehrt Query aus und gibt einzelnes Ergebnis zurueck."""
    rows = execute_query(query, params, max_rows=1)
    return rows[0] if rows else None
← Übersicht