инициализировал проект api
This commit is contained in:
parent
1bdcdba11f
commit
d81875c113
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/api/.env
|
||||
0
api/app/__init__.py
Normal file
0
api/app/__init__.py
Normal file
11
api/app/core/config.py
Normal file
11
api/app/core/config.py
Normal 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()
|
||||
0
api/app/infrastructure/database/models/__init__.py
Normal file
0
api/app/infrastructure/database/models/__init__.py
Normal file
13
api/app/infrastructure/database/session.py
Normal file
13
api/app/infrastructure/database/session.py
Normal 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
0
api/app/main.py
Normal file
Loading…
x
Reference in New Issue
Block a user