(
self,
dsn: str,
)
| 10 | conn = None |
| 11 | |
| 12 | def __init__( |
| 13 | self, |
| 14 | dsn: str, |
| 15 | ): |
| 16 | self.dsn = dsn |
| 17 | self.database_url = f"{self.dsn}" |
| 18 | |
| 19 | self.engine = create_async_engine( |
| 20 | self.database_url, |
| 21 | echo=False, |
| 22 | pool_pre_ping=True, |
| 23 | poolclass=StaticPool, |
| 24 | connect_args={"charset": "utf8mb4", "cursorclass": aiomysql.SSCursor}, |
| 25 | ) |
| 26 | |
| 27 | self.async_session_factory = async_sessionmaker( |
| 28 | bind=self.engine, |
| 29 | class_=AsyncSession, |
| 30 | expire_on_commit=False, |
| 31 | ) |
| 32 | |
| 33 | @asynccontextmanager |
| 34 | async def session(self) -> AsyncGenerator[AsyncSession]: |
nothing calls this directly
no outgoing calls
no test coverage detected