endpoint_biblioteca_funcionando

This commit is contained in:
2025-05-10 20:08:51 +02:00
parent c47b9474f4
commit b34d52036e
12 changed files with 123 additions and 55 deletions
+7 -16
View File
@@ -1,19 +1,10 @@
# backend/db/conexion.py
from entrypoint.init_db import db_credencial
from src.ConexionSql.Postgres_conexion import PostgresConexion
from src.Credenciales.postgres_credencial import PostgresCredencial
from dotenv import load_dotenv
import os
from entrypoint import ENV_PATH
# Cargar .env
load_dotenv(ENV_PATH)
def get_conexion():
db_credencial = PostgresCredencial(
titulo=os.getenv("DB_TITLE"),
user=os.getenv("DB_USER"),
password=os.getenv("DB_PASSWORD"),
host=os.getenv("DB_HOST"),
port=os.getenv("DB_PORT"),
dbname=os.getenv("DB_NAME")
)
return PostgresConexion(db_credencial)
conexion = PostgresConexion(db_credencial)
try:
yield conexion
finally:
conexion.close()