lint con ruff

This commit is contained in:
2025-09-22 22:30:54 +02:00
parent 35527c89cd
commit fb2b2724ed
54 changed files with 585 additions and 432 deletions

View File

@@ -1,9 +1,11 @@
import logging
import mysql.connector
from mysql.connector import Error
logger = logging.getLogger(__name__)
def connetti_db(cfg: object) -> object:
"""
Establishes a connection to a MySQL database.
@@ -21,14 +23,10 @@ def connetti_db(cfg: object) -> object:
A MySQL connection object if the connection is successful, otherwise None.
"""
try:
conn = mysql.connector.connect(user=cfg.dbuser,
password=cfg.dbpass,
host=cfg.dbhost,
port=cfg.dbport,
database=cfg.dbname)
conn = mysql.connector.connect(user=cfg.dbuser, password=cfg.dbpass, host=cfg.dbhost, port=cfg.dbport, database=cfg.dbname)
conn.autocommit = True
logger.info("Connected")
return conn
except Error as e:
logger.error(f"Database connection error: {e}")
raise # Re-raise the exception to be handled by the caller
raise # Re-raise the exception to be handled by the caller