class AsyncEngine(ProxyComparable, AsyncConnectable):
An asyncio proxy for a _engine.Engine
.
_asyncio.AsyncEngine
is acquired using the
_asyncio.create_async_engine
function:
from sqlalchemy.ext.asyncio import create_async_engine engine = create_async_engine("postgresql+asyncpg://user:pass@host/dbname")
Class | _trans_ctx |
Undocumented |
Class Method | _regenerate_proxy_for_target |
Undocumented |
Method | __init__ |
Undocumented |
Method | begin |
Return a context manager which when entered will deliver an _asyncio.AsyncConnection with an _asyncio.AsyncTransaction established. |
Method | connect |
Return an _asyncio.AsyncConnection object. |
Async Method | dispose |
Dispose of the connection pool used by this _asyncio.AsyncEngine . |
Method | execution_options |
Return a new _asyncio.AsyncEngine that will provide _asyncio.AsyncConnection objects with the given execution options. |
Async Method | raw_connection |
Return a "raw" DBAPI connection from the connection pool. |
Class Variable | __slots__ |
Undocumented |
Class Variable | _option_cls |
Undocumented |
Instance Variable | _proxied |
Undocumented |
Instance Variable | sync_engine |
Reference to the sync-style _engine.Engine this _asyncio.AsyncEngine proxies requests towards. |
Inherited from ProxyComparable
:
Method | __eq__ |
Undocumented |
Method | __hash__ |
Undocumented |
Method | __ne__ |
Undocumented |
Inherited from ReversibleProxy
(via ProxyComparable
):
Class Method | _retrieve_proxy_for_target |
Undocumented |
Class Method | _target_gced |
Undocumented |
Method | _assign_proxied |
Undocumented |
Class Variable | _proxy_objects |
Undocumented |
Return a context manager which when entered will deliver an
_asyncio.AsyncConnection
with an
_asyncio.AsyncTransaction
established.
E.g.:
async with async_engine.begin() as conn: await conn.execute( text("insert into table (x, y, z) values (1, 2, 3)") ) await conn.execute(text("my_special_procedure(5)"))
Return an _asyncio.AsyncConnection
object.
The _asyncio.AsyncConnection
will procure a database
connection from the underlying connection pool when it is entered
as an async context manager:
async with async_engine.connect() as conn: result = await conn.execute(select(user_table))
The _asyncio.AsyncConnection
may also be started outside of a
context manager by invoking its _asyncio.AsyncConnection.start
method.
Dispose of the connection pool used by this
_asyncio.AsyncEngine
.
This will close all connection pool connections that are
currently checked in. See the documentation for the underlying
_future.Engine.dispose
method for further notes.
See Also
_future.Engine.dispose
Return a new _asyncio.AsyncEngine
that will provide
_asyncio.AsyncConnection
objects with the given execution
options.
Proxied from _future.Engine.execution_options
. See that
method for details.