14 lines
477 B
Python
14 lines
477 B
Python
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
|
|
from sqlalchemy.orm import sessionmaker, declarative_base
|
|
|
|
DATABASE_URL = "postgresql+asyncpg://weather_user:weather_pass@db:5432/weather"
|
|
|
|
engine = create_async_engine(DATABASE_URL, echo=False)
|
|
AsyncSessionLocal = sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False)
|
|
|
|
Base = declarative_base()
|
|
|
|
async def get_session():
|
|
async with AsyncSessionLocal() as session:
|
|
yield session
|