class AsyncEngine(ProxyComparable[
An asyncio proxy for a :class:`_engine.Engine`. :class:`_asyncio.AsyncEngine` is acquired using the :func:`_asyncio.create_async_engine` function:: from sqlalchemy.ext.asyncio import create_async_engine engine = create_async_engine("postgresql+asyncpg://user:pass@host/dbname") .. versionadded:: 1.4
Method | __init__ |
Undocumented |
Async Method | begin |
Return a context manager which when entered will deliver an :class:`_asyncio.AsyncConnection` with an :class:`_asyncio.AsyncTransaction` established. |
Method | clear |
Clear the compiled cache associated with the dialect. |
Method | connect |
Return an :class:`_asyncio.AsyncConnection` object. |
Method | dialect |
Undocumented |
Async Method | dispose |
Dispose of the connection pool used by this :class:`_asyncio.AsyncEngine`. |
Method | echo |
Undocumented |
Method | execution |
Return a new :class:`_asyncio.AsyncEngine` that will provide :class:`_asyncio.AsyncConnection` objects with the given execution options. |
Method | get |
Get the non-SQL options which will take effect during execution. |
Method | pool |
Undocumented |
Async Method | raw |
Return a "raw" DBAPI connection from the connection pool. |
Method | update |
Update the default execution_options dictionary of this :class:`_engine.Engine`. |
Method | url |
Undocumented |
Class Variable | __slots__ |
Undocumented |
Instance Variable | sync |
Reference to the sync-style :class:`_engine.Engine` this :class:`_asyncio.AsyncEngine` proxies requests towards. |
Property | dialect |
Proxy for the :attr:`_engine.Engine.dialect` attribute on behalf of the :class:`_asyncio.AsyncEngine` class. |
Property | driver |
Driver name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`. |
Property | echo |
When ``True``, enable log output for this element. |
Property | engine |
Returns this :class:`.Engine`. |
Property | name |
String name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`. |
Property | pool |
Proxy for the :attr:`_engine.Engine.pool` attribute on behalf of the :class:`_asyncio.AsyncEngine` class. |
Property | url |
Proxy for the :attr:`_engine.Engine.url` attribute on behalf of the :class:`_asyncio.AsyncEngine` class. |
Class Method | _regenerate |
Undocumented |
Property | _proxied |
Undocumented |
Inherited from ProxyComparable
:
Method | __eq__ |
Undocumented |
Method | __hash__ |
Undocumented |
Method | __ne__ |
Undocumented |
Inherited from ReversibleProxy
(via ProxyComparable
):
Class Method | _retrieve |
Undocumented |
Class Method | _target |
Undocumented |
Method | _assign |
Undocumented |
Class Variable | _proxy |
Undocumented |
Inherited from AsyncConnectable
(via ProxyComparable
, ReversibleProxy
):
Class Method | _no |
Undocumented |
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("insert into table (x, y, z) values (1, 2, 3)") ) await conn.execute(text("my_special_procedure(5)"))
Clear the compiled cache associated with the dialect. .. container:: class_bases Proxied for the :class:`_engine.Engine` class on behalf of the :class:`_asyncio.AsyncEngine` class. This applies **only** to the built-in cache that is established via the :paramref:`_engine.create_engine.query_cache_size` parameter. It will not impact any dictionary caches that were passed via the :paramref:`.Connection.execution_options.query_cache` parameter. .. versionadded:: 1.4
Return an :class:`_asyncio.AsyncConnection` object. The :class:`_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 :class:`_asyncio.AsyncConnection` may also be started outside of a context manager by invoking its :meth:`_asyncio.AsyncConnection.start` method.
Dispose of the connection pool used by this :class:`_asyncio.AsyncEngine`. :param close: if left at its default of ``True``, has the effect of fully closing all **currently checked in** database connections. Connections that are still checked out will **not** be closed, however they will no longer be associated with this :class:`_engine.Engine`, so when they are closed individually, eventually the :class:`_pool.Pool` which they are associated with will be garbage collected and they will be closed out fully, if not already closed on checkin. If set to ``False``, the previous connection pool is de-referenced, and otherwise not touched in any way. .. seealso:: :meth:`_engine.Engine.dispose`
Optional[ CompiledCacheType]
= ..., logging_token: str
= ..., isolation_level: IsolationLevel
= ..., insertmanyvalues_page_size: int
= ..., schema_translate_map: Optional[ SchemaTranslateMapType]
= ..., **opt: Any
) -> AsyncEngine
:(source) ¶
Return a new :class:`_asyncio.AsyncEngine` that will provide :class:`_asyncio.AsyncConnection` objects with the given execution options. Proxied from :meth:`_engine.Engine.execution_options`. See that method for details.
Get the non-SQL options which will take effect during execution. .. container:: class_bases Proxied for the :class:`_engine.Engine` class on behalf of the :class:`_asyncio.AsyncEngine` class. .. versionadded: 1.3 .. seealso:: :meth:`_engine.Engine.execution_options`
Update the default execution_options dictionary of this :class:`_engine.Engine`. .. container:: class_bases Proxied for the :class:`_engine.Engine` class on behalf of the :class:`_asyncio.AsyncEngine` class. The given keys/values in \**opt are added to the default execution options that will be used for all connections. The initial contents of this dictionary can be sent via the ``execution_options`` parameter to :func:`_sa.create_engine`. .. seealso:: :meth:`_engine.Connection.execution_options` :meth:`_engine.Engine.execution_options`
Reference to the sync-style :class:`_engine.Engine` this :class:`_asyncio.AsyncEngine` proxies requests towards. This instance can be used as an event target. .. seealso:: :ref:`asyncio_events`
Proxy for the :attr:`_engine.Engine.dialect` attribute on behalf of the :class:`_asyncio.AsyncEngine` class.
Driver name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`. .. container:: class_bases Proxied for the :class:`_engine.Engine` class on behalf of the :class:`_asyncio.AsyncEngine` class.
When ``True``, enable log output for this element. .. container:: class_bases Proxied for the :class:`_engine.Engine` class on behalf of the :class:`_asyncio.AsyncEngine` class. This has the effect of setting the Python logging level for the namespace of this element's class and object reference. A value of boolean ``True`` indicates that the loglevel ``logging.INFO`` will be set for the logger, whereas the string value ``debug`` will set the loglevel to ``logging.DEBUG``.
Returns this :class:`.Engine`. .. container:: class_bases Proxied for the :class:`_engine.Engine` class on behalf of the :class:`_asyncio.AsyncEngine` class. Used for legacy schemes that accept :class:`.Connection` / :class:`.Engine` objects within the same variable.
String name of the :class:`~sqlalchemy.engine.interfaces.Dialect` in use by this :class:`Engine`. .. container:: class_bases Proxied for the :class:`_engine.Engine` class on behalf of the :class:`_asyncio.AsyncEngine` class.
Proxy for the :attr:`_engine.Engine.pool` attribute on behalf of the :class:`_asyncio.AsyncEngine` class.
Proxy for the :attr:`_engine.Engine.url` attribute on behalf of the :class:`_asyncio.AsyncEngine` class.