12345678910111213141516171819 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
- from sqlalchemy.orm import sessionmaker
- from core.config import settings
- async_engine = create_async_engine(settings.ASYNC_MYSQL_URI,
- pool_size=30,
- max_overflow=20,
- pool_pre_ping=True)
- LocalAsyncSession = sessionmaker(class_=AsyncSession,
- autocommit=False,
- autoflush=False,
- bind=async_engine)
- __all__ = ["LocalAsyncSession"]
|