endpoint_biblioteca_funcionando
This commit is contained in:
+7
-16
@@ -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()
|
||||
Reference in New Issue
Block a user