Spaces:
Sleeping
Sleeping
Download api/monitoring/db.py from donizetti-yoann/agritech-api: direct link, hf CLI and curl.
- Browser
- Download file 590 Bytes
-
https://huggingface.co/spaces/donizetti-yoann/agritech-api/resolve/main/api/monitoring/db.py
- Command line
-
hf download hf://spaces/donizetti-yoann/agritech-api/api/monitoring/db.py
-
curl -L -o db.py https://huggingface.co/spaces/donizetti-yoann/agritech-api/resolve/main/api/monitoring/db.py
590 Bytes
| import psycopg2 | |
| from src.config import ( | |
| POSTGRES_HOST, | |
| POSTGRES_PORT, | |
| POSTGRES_DB, | |
| POSTGRES_USER, | |
| POSTGRES_PASSWORD, | |
| POSTGRES_SSLMODE, | |
| ) | |
| def get_connection(): | |
| """Établit une connexion à la base de données PostgreSQL et la retourne. | |
| Returns: | |
| psycopg2.extensions.connection: Un objet de connexion à la base de données. | |
| """ | |
| return psycopg2.connect( | |
| host=POSTGRES_HOST, | |
| port=POSTGRES_PORT, | |
| dbname=POSTGRES_DB, | |
| user=POSTGRES_USER, | |
| password=POSTGRES_PASSWORD, | |
| sslmode=POSTGRES_SSLMODE, | |
| ) |