Update modules/database.py
Browse files- modules/database.py +5 -10
modules/database.py
CHANGED
|
@@ -45,28 +45,23 @@ def initialize_cosmos_sql_connection():
|
|
| 45 |
cosmos_key = os.environ.get("COSMOS_KEY")
|
| 46 |
logger.info(f"Cosmos Endpoint: {cosmos_endpoint}")
|
| 47 |
logger.info(f"Cosmos Key: {'*' * len(cosmos_key) if cosmos_key else 'Not set'}")
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
print(f"Cosmos Key: {'*' * len(cosmos_key) if cosmos_key else 'Not set'}")
|
| 51 |
-
|
| 52 |
-
if not cosmos_endpoint or not cosmos_key:logger.error("COSMOS_ENDPOINT or COSMOS_KEY environment variables are not set")
|
| 53 |
logger.error("COSMOS_ENDPOINT or COSMOS_KEY environment variables are not set")
|
| 54 |
raise ValueError("Las variables de entorno COSMOS_ENDPOINT y COSMOS_KEY deben estar configuradas")
|
| 55 |
-
|
| 56 |
cosmos_client = CosmosClient(cosmos_endpoint, cosmos_key)
|
| 57 |
user_database = cosmos_client.get_database_client("user_database")
|
| 58 |
user_container = user_database.get_container_client("users")
|
| 59 |
application_requests_container = user_database.get_container_client("application_requests")
|
| 60 |
-
|
| 61 |
logger.info(f"user_container initialized: {user_container is not None}")
|
| 62 |
logger.info(f"application_requests_container initialized: {application_requests_container is not None}")
|
| 63 |
|
| 64 |
-
print(f"user_container initialized: {user_container is not None}")
|
| 65 |
-
|
| 66 |
logger.info("Conexi贸n a Cosmos DB SQL API exitosa")
|
| 67 |
return True
|
| 68 |
except Exception as e:
|
| 69 |
-
logger.error(f"Error al conectar con Cosmos DB SQL API: {str(e)}")
|
| 70 |
return False
|
| 71 |
|
| 72 |
############################################################################################3
|
|
|
|
| 45 |
cosmos_key = os.environ.get("COSMOS_KEY")
|
| 46 |
logger.info(f"Cosmos Endpoint: {cosmos_endpoint}")
|
| 47 |
logger.info(f"Cosmos Key: {'*' * len(cosmos_key) if cosmos_key else 'Not set'}")
|
| 48 |
+
|
| 49 |
+
if not cosmos_endpoint or not cosmos_key:
|
|
|
|
|
|
|
|
|
|
| 50 |
logger.error("COSMOS_ENDPOINT or COSMOS_KEY environment variables are not set")
|
| 51 |
raise ValueError("Las variables de entorno COSMOS_ENDPOINT y COSMOS_KEY deben estar configuradas")
|
| 52 |
+
|
| 53 |
cosmos_client = CosmosClient(cosmos_endpoint, cosmos_key)
|
| 54 |
user_database = cosmos_client.get_database_client("user_database")
|
| 55 |
user_container = user_database.get_container_client("users")
|
| 56 |
application_requests_container = user_database.get_container_client("application_requests")
|
| 57 |
+
|
| 58 |
logger.info(f"user_container initialized: {user_container is not None}")
|
| 59 |
logger.info(f"application_requests_container initialized: {application_requests_container is not None}")
|
| 60 |
|
|
|
|
|
|
|
| 61 |
logger.info("Conexi贸n a Cosmos DB SQL API exitosa")
|
| 62 |
return True
|
| 63 |
except Exception as e:
|
| 64 |
+
logger.error(f"Error al conectar con Cosmos DB SQL API: {str(e)}", exc_info=True)
|
| 65 |
return False
|
| 66 |
|
| 67 |
############################################################################################3
|