import fdb import mysql.connector from app.config import logger def get_factuges_connection(config): try: conn = fdb.connect( host=config['FACTUGES_HOST'], port=int(config['FACTUGES_PORT']), database=config['FACTUGES_DATABASE'], user=config['FACTUGES_USER'], password=config['FACTUGES_PASSWORD'], charset='UTF8' ) logger.info( f"Conexión a la base de datos FactuGES establecida: {config['FACTUGES_HOST']} with database:{config['FACTUGES_DATABASE']} - using user:{config['FACTUGES_USER']}") return conn except Exception as e: logger.error("Error al conectar a la base de datos FactuGES.") logger.error( f"(ERROR) Failed to establish connection to: {config['FACTUGES_HOST']} with database:{config['FACTUGES_DATABASE']} - using user:{config['FACTUGES_USER']}") logger.error(str(e)) raise e def get_mysql_connection(config): try: conn = mysql.connector.connect( host=config['FWEB_MYSQL_HOST'], port=config['FWEB_MYSQL_PORT'], database=config['FWEB_MYSQL_DATABASE'], user=config['FWEB_MYSQL_USER'], password=config['FWEB_MYSQL_PASSWORD'] ) logger.info( f"Conexión a la base de datos MySQL establecida a: {config['FWEB_MYSQL_HOST']} with database:{config['FWEB_MYSQL_DATABASE']} - using user:{config['FWEB_MYSQL_USER']}") return conn except Exception as e: logger.error("Error al conectar a la base de datos MySQL.") logger.error( f"(ERROR) Failed to establish connection to: {config['FWEB_MYSQL_HOST']} with database:{config['FWEB_MYSQL_DATABASE']} - using user:{config['FWEB_MYSQL_USER']}") logger.error(str(e)) raise e