Spaces:
Runtime error
Runtime error
Download app/database/connection.py from Vinit006/EmailAgentwithMemory: direct link, hf CLI and curl.
- Browser
- Download file 755 Bytes
-
https://huggingface.co/spaces/Vinit006/EmailAgentwithMemory/resolve/f4e5ae0c5c18fa1379edfe78efc8c05d0791c899/app/database/connection.py
- Command line
-
hf download hf://spaces/Vinit006/EmailAgentwithMemory@f4e5ae0c5c18fa1379edfe78efc8c05d0791c899/app/database/connection.py
-
curl -L -o connection.py https://huggingface.co/spaces/Vinit006/EmailAgentwithMemory/resolve/f4e5ae0c5c18fa1379edfe78efc8c05d0791c899/app/database/connection.py
755 Bytes
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import sessionmaker, Session | |
| from app.core.config import settings | |
| from psycopg_pool import ConnectionPool | |
| from contextlib import contextmanager | |
| DB_URL_FOR_CHECKPOINTER_STORE=settings.DB_URL_FOR_CHECKPOINTER_STORE | |
| pool = ConnectionPool( | |
| conninfo=DB_URL_FOR_CHECKPOINTER_STORE, | |
| min_size=1, | |
| max_size=10, | |
| kwargs={"autocommit": True} | |
| ) | |
| DB_URL_FOR_SQL_AL=settings.DB_URL_FOR_SQL_AL | |
| engine = create_engine( | |
| DB_URL_FOR_SQL_AL, | |
| echo=False, | |
| pool_pre_ping=True, | |
| pool_recycle=1800 | |
| ) | |
| SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False) | |
| def get_session(): | |
| db = SessionLocal() | |
| try: | |
| yield db | |
| finally: | |
| db.close() | |