feat: project scaffold (FastAPI backend, React frontend, aiogram bot, docker-compose, CI/CD)
This commit is contained in:
1 parent
066deaca47
commit
71460ab56a
37 files changed
+936
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,23 @@
|
||||
"""Подключение к БД и сессии SQLAlchemy."""
|
||||
from collections.abc import Generator
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import DeclarativeBase, Session, sessionmaker
|
||||
|
||||
from app.core.config import settings
|
||||
|
||||
engine = create_engine(settings.database_url, pool_pre_ping=True, future=True)
|
||||
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False, future=True)
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
"""Базовый класс моделей."""
|
||||
|
||||
|
||||
def get_db() -> Generator[Session, None, None]:
|
||||
"""Зависимость FastAPI: сессия БД."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
finally:
|
||||
db.close()
|
||||
Reference in new issue
Block a user