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>
26 lines
485 B
Python
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()
|