Spaces:
Sleeping
Sleeping
Download app/cores/database.py from abdullah090809/Job_Tracker_API: direct link, hf CLI and curl.
- Browser
- Download file 587 Bytes
-
https://huggingface.co/spaces/abdullah090809/Job_Tracker_API/resolve/main/app/cores/database.py
- Command line
-
hf download hf://spaces/abdullah090809/Job_Tracker_API/app/cores/database.py
-
curl -L -o database.py https://huggingface.co/spaces/abdullah090809/Job_Tracker_API/resolve/main/app/cores/database.py
587 Bytes
| from typing import final | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import declarative_base, sessionmaker | |
| from app.cores.config import settings | |
| SQLALCHEMY_DATABASE_URL = f"postgresql://{settings.DATABASE_USERNAME}:{settings.DATABASE_PASSWORD}@{settings.DATABASE_HOSTNAME}:{settings.DATABASE_PORT}/{settings.DATABASE_NAME}" | |
| engine = create_engine(SQLALCHEMY_DATABASE_URL) | |
| SessionLocal = sessionmaker(autocommit=False,autoflush=False,bind=engine) | |
| Base = declarative_base() | |
| def get_db(): | |
| db = SessionLocal() | |
| try: | |
| yield db | |
| finally: | |
| db.close() | |