613cd90662
- Implemented OpenAICredencial class for managing OpenAI API keys. - Created OpenAICredencialModel and OpenAICredencialMapper for SQLAlchemy integration. - Developed OpenAICredencialRepo for CRUD operations on OpenAI credentials. - Established OpenAICliente class for interacting with OpenAI API. - Introduced PostgresCredencial class for managing PostgreSQL connection details. - Created PostgresCredencialModel and PostgresCredencialMapper for SQLAlchemy integration. - Developed PostgresCredencialRepo for CRUD operations on PostgreSQL credentials. - Added base connection class and PostgreSQL connection implementation. - Included environment variable loading for sensitive data management.
144 lines
2.7 KiB
Plaintext
144 lines
2.7 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "5206b9c6",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from src.ConexionSql.Postgres_conexion import PostgresConexion\n",
|
|
"from src.Credenciales.postgres_credencial_mmr import PostgresCredencialRepo\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "63a0b954",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from entrypoint.init_db import db_credencial\n",
|
|
"conexion_admin = PostgresConexion(db_credencial)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "0575f424",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"\n",
|
|
"repo_cred = PostgresCredencialRepo(conexion_admin)\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "a5266309",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"1"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"repo_cred.add(db_credencial)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "670c79b7",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Production_Fitz_db\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"modelo_cred = repo_cred.get_by_id(1)\n",
|
|
"\n",
|
|
"print(modelo_cred.titulo)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"id": "6cf421c7",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Estado de conexión: exito\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Conectar con la base de datos utilizando el modelo recuperado\n",
|
|
"conexion_db = PostgresConexion(modelo_cred)\n",
|
|
"# Verificar estado de conexión\n",
|
|
"estado = \"exito\" if conexion_db.probar_conexion() else \"fallo\"\n",
|
|
"\n",
|
|
"print(f\"Estado de conexión: {estado}\")\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"id": "feba1446",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"7Souw9SFD5P5RYpRWuTVvFkY7zlxATcN\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(modelo_cred.password)"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.11.11"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|