From 90f91a22f2dc7f159d426a2f54337584b2d6375b Mon Sep 17 00:00:00 2001 From: Dmitry Titenkov Date: Fri, 20 Feb 2026 12:34:00 +0300 Subject: [PATCH] omg --- README.md | 2 +- app/core/base.py | 0 app/core/config.py | 1 + app/core/database.py | 19 +++++++++++++++++++ app/main.py | 4 ++-- app/models/words.py | 0 6 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 app/core/base.py create mode 100644 app/core/database.py create mode 100644 app/models/words.py diff --git a/README.md b/README.md index 4e0cc21..8479cf4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# world_flow +# word_flow API тренировки английского и Telegram бот diff --git a/app/core/base.py b/app/core/base.py new file mode 100644 index 0000000..e69de29 diff --git a/app/core/config.py b/app/core/config.py index 01d5de2..8ee1716 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -5,6 +5,7 @@ class Settings(BaseSettings): app_title: str description: str database_url: str + debug: bool model_config = {"env_file": ".env", "extra": "ignore"} diff --git a/app/core/database.py b/app/core/database.py new file mode 100644 index 0000000..d48d32b --- /dev/null +++ b/app/core/database.py @@ -0,0 +1,19 @@ +from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine +from sqlalchemy.orm import DeclarativeBase + +from app.core.config import settings + +engine = create_async_engine( + settings.database_url, echo=settings.debug, future=True +) + +async_session = async_sessionmaker(engine, expire_on_commit=False) + + +class Base(DeclarativeBase): + pass + + +async def get_session(): + async with async_session() as session: + yield session diff --git a/app/main.py b/app/main.py index ba8944f..6f38f8c 100644 --- a/app/main.py +++ b/app/main.py @@ -13,9 +13,9 @@ @asynccontextmanager async def lifespan(app: FastAPI): - logging.info("Приложение World Flow запущено") + logging.info("Приложение Word Flow запущено") yield - logging.info("Приложение World Flow остановлено") + logging.info("Приложение Word Flow остановлено") app = FastAPI( diff --git a/app/models/words.py b/app/models/words.py new file mode 100644 index 0000000..e69de29