Primer commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
# entrypoint/init_db.py
|
||||
|
||||
from backend.base import Base
|
||||
from backend.ConexionSql.Postgres_conexion import PostgresConexion # Asegúrate de tener esta clase implementada correctamente
|
||||
from backend.Credenciales.postgres_credencial import PostgresCredencial # Asegúrate de tener esta clase implementada correctamente
|
||||
|
||||
from backend.Credenciales.postgres_credencial_mmr import PostgresCredencialModel
|
||||
from backend.ApiKeys.openai_apikey_mmr import OpenAICredencialModel
|
||||
from llms.Modelos.Openai_model_mmr import ModeloOpenAIConfigModel
|
||||
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
from entrypoint import ENV_PATH
|
||||
|
||||
# Ruta específica al archivo .env
|
||||
dotenv_path = ENV_PATH
|
||||
|
||||
# Cargar el archivo
|
||||
load_dotenv(dotenv_path)
|
||||
|
||||
titulo = os.getenv('DB_TITLE')
|
||||
usuario = os.getenv('DB_USER')
|
||||
passwrd = os.getenv('DB_PASSWORD')
|
||||
host = os.getenv('DB_HOST')
|
||||
port = os.getenv('DB_PORT')
|
||||
db_name = os.getenv('DB_NAME')
|
||||
|
||||
|
||||
db_credencial = PostgresCredencial(
|
||||
titulo=titulo,
|
||||
user=usuario,
|
||||
password=passwrd,
|
||||
host=host,
|
||||
port=port,
|
||||
dbname=db_name
|
||||
)
|
||||
|
||||
|
||||
def init_db():
|
||||
|
||||
# Crear engine desde la clase de conexión PostgreSQL
|
||||
conexion = PostgresConexion(db_credencial)
|
||||
engine = conexion.engine # Recuperamos el engine directamente
|
||||
|
||||
print("Creando tablas...")
|
||||
Base.metadata.create_all(engine)
|
||||
print("¡Listo!")
|
||||
Reference in New Issue
Block a user