Spaces:
Runtime error
Runtime error
Download app/database.py from abdullah090809/FastAPI-Project: direct link, hf CLI and curl.
- Browser
- Download file 583 Bytes
-
https://huggingface.co/spaces/abdullah090809/FastAPI-Project/resolve/c8a050e5e14e98f3a0c78f650957e331a865e381/app/database.py
- Command line
-
hf download hf://spaces/abdullah090809/FastAPI-Project@c8a050e5e14e98f3a0c78f650957e331a865e381/app/database.py
-
curl -L -o database.py https://huggingface.co/spaces/abdullah090809/FastAPI-Project/resolve/c8a050e5e14e98f3a0c78f650957e331a865e381/app/database.py
583 Bytes
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import sessionmaker | |
| from app.config import setting | |
| SQLALCHEMY_DATABASE_URL=f"postgresql://{setting.database_username}:{setting.database_password}@{setting.database_hostname}:{setting.database_port}/{setting.database_name}" | |
| engine = create_engine(SQLALCHEMY_DATABASE_URL) | |
| SessionMaker = sessionmaker(autoflush=False,autocommit=False,bind=engine) | |
| Base = declarative_base() | |
| def get_db(): | |
| db = SessionMaker() | |
| try: | |
| yield db | |
| finally: | |
| db.close() |