Files
fastAPI/app/core/database.py
Misaka_Company 8292de7747 refactor: update database.py to use new config module
Update import statement from app.core.config to config.settings as part
of YAML configuration migration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-12 09:37:52 +08:00

26 lines
485 B
Python

from typing import Generator
from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase, Session, sessionmaker
from config.settings import settings
engine = create_engine(
settings.database_url,
pool_pre_ping=True,
pool_recycle=1800,
)
SessionLocal = sessionmaker(bind=engine)
class Base(DeclarativeBase):
pass
def get_db() -> Generator[Session, None, None]:
db = SessionLocal()
try:
yield db
finally:
db.close()