Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé
Classe « AdaptedConnection »

Méthode sqlalchemy.AdaptedConnection.run_async

Signature de la méthode run_async

def run_async(self, fn: 'Callable[[Any], Awaitable[_T]]') -> '_T' 

Description

help(AdaptedConnection.run_async)

Run the awaitable returned by the given function, which is passed
the raw asyncio driver connection.

This is used to invoke awaitable-only methods on the driver connection
within the context of a "synchronous" method, like a connection
pool event handler.

E.g.::

    engine = create_async_engine(...)


    @event.listens_for(engine.sync_engine, "connect")
    def register_custom_types(
        dbapi_connection,  # ...
    ):
        dbapi_connection.run_async(
            lambda connection: connection.set_type_codec(
                "MyCustomType", encoder, decoder, ...
            )
        )

.. versionadded:: 1.4.30

.. seealso::

    :ref:`asyncio_events_run_async`



Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les fondamentaux
Voir le programme détaillé