инициализировал проект api

This commit is contained in:
Андрей Дувакин 2025-01-31 19:31:43 +05:00
parent 1bdcdba11f
commit d81875c113
6 changed files with 25 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/api/.env

0
api/app/__init__.py Normal file
View File

11
api/app/core/config.py Normal file
View File

@ -0,0 +1,11 @@
from pydantic import BaseSettings
class Settings(BaseSettings):
DATABASE_URL: str = "postgresql+asyncpg://user:password@localhost:5432/dbname"
class Config:
env_file = ".env"
settings = Settings()

View File

@ -0,0 +1,13 @@
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker
from app.core.config import settings
engine = create_async_engine(settings.DATABASE_URL, echo=True)
async_session_maker = sessionmaker(
bind=engine, class_=AsyncSession, expire_on_commit=False
)
async def get_db():
async with async_session_maker() as session:
yield session

0
api/app/main.py Normal file
View File