new bot structure
This commit is contained in:
12
app/infrastructure/database/database.py
Normal file
12
app/infrastructure/database/database.py
Normal file
@@ -0,0 +1,12 @@
|
||||
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
|
||||
Reference in New Issue
Block a user