MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / begin

Method begin

lib/sqlalchemy/ext/asyncio/engine.py:1070–1088  ·  view source on GitHub ↗

Return a context manager which when entered will deliver an :class:`_asyncio.AsyncConnection` with an :class:`_asyncio.AsyncTransaction` established. E.g.:: async with async_engine.begin() as conn: await conn.execute( text("in

(self)

Source from the content-addressed store, hash-verified

1068
1069 @contextlib.asynccontextmanager
1070 async def begin(self) -> AsyncIterator[AsyncConnection]:
1071 """Return a context manager which when entered will deliver an
1072 :class:`_asyncio.AsyncConnection` with an
1073 :class:`_asyncio.AsyncTransaction` established.
1074
1075 E.g.::
1076
1077 async with async_engine.begin() as conn:
1078 await conn.execute(
1079 text("insert into table (x, y, z) values (1, 2, 3)")
1080 )
1081 await conn.execute(text("my_special_procedure(5)"))
1082
1083 """
1084 conn = self.connect()
1085
1086 async with conn:
1087 async with conn.begin():
1088 yield conn
1089
1090 def connect(self) -> AsyncConnection:
1091 """Return an :class:`_asyncio.AsyncConnection` object.

Callers

nothing calls this directly

Calls 1

connectMethod · 0.95

Tested by

no test coverage detected