13 lines
435 B
Python
13 lines
435 B
Python
from config import DATABASE_URL
|
|
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
|
|
from sqlalchemy.orm import declarative_base, sessionmaker
|
|
|
|
engine = create_async_engine(DATABASE_URL, echo=True)
|
|
Base = declarative_base()
|
|
async_session = sessionmaker(bind=engine, expire_on_commit=False, class_=AsyncSession)
|
|
|
|
|
|
async def get_session() -> AsyncSession:
|
|
async with async_session() as session:
|
|
yield session
|