MCPcopy Create free account
hub / github.com/dbunt1tled/python-fast-api / __init__

Method __init__

src/core/db/asmysql.py:12–31  ·  view source on GitHub ↗
(
        self,
        dsn: str,
    )

Source from the content-addressed store, hash-verified

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]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected