Download document-service/app/utils/database.py from ans123/MIRA_LABS_AI: direct link, hf CLI and curl.
- Browser
- Download file 458 Bytes
-
https://huggingface.co/ans123/MIRA_LABS_AI/resolve/main/document-service/app/utils/database.py
- Command line
-
hf download hf://ans123/MIRA_LABS_AI/document-service/app/utils/database.py
-
curl -L -o database.py https://huggingface.co/ans123/MIRA_LABS_AI/resolve/main/document-service/app/utils/database.py
458 Bytes
| from sqlalchemy.orm import sessionmaker | |
| from sqlalchemy import create_engine | |
| from app.config.env import env | |
| DATABASE_CONNECTION_URI = env.DB_URI | |
| engine = create_engine(DATABASE_CONNECTION_URI) | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| async def get_db(): | |
| db = SessionLocal() | |
| try: | |
| yield db | |
| finally: | |
| db.close() | |
| def get_db_service(): | |
| db = SessionLocal() | |
| return db | |