All checks were successful
hufs-notice-crawler-cicd / build_push_deploy (push) Successful in 8m35s
34 lines
529 B
Python
34 lines
529 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import DeclarativeBase, sessionmaker
|
|
|
|
from app.config import get_settings
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
settings = get_settings()
|
|
|
|
engine = create_engine(
|
|
settings.database_url,
|
|
future=True,
|
|
pool_pre_ping=True,
|
|
)
|
|
|
|
SessionLocal = sessionmaker(
|
|
bind=engine,
|
|
autoflush=False,
|
|
autocommit=False,
|
|
future=True,
|
|
expire_on_commit=False,
|
|
)
|
|
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|