Spaces:
Sleeping
Sleeping
| from sqlalchemy import create_engine | |
| from sqlalchemy.exc import SQLAlchemyError | |
| from sqlalchemy.orm import sessionmaker | |
| from app.core.config import settings | |
| # engine_url = settings.DATABASE_URL | |
| # engine_url = "postgresql://postgres:RTX4060@localhost:5432/Brain_Tumor_Project" | |
| DATABASE_URL = settings.DATABASE_URL | |
| engine = create_engine( | |
| DATABASE_URL, | |
| pool_pre_ping=True, | |
| pool_recycle=300, | |
| ) | |
| SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False) | |
| def get_db(): | |
| db = SessionLocal() | |
| try: | |
| yield db | |
| finally: | |
| db.close() |