
    ,h              	         S SK Jr  S SKrS SKrS SKJr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SKJ
r
  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK J!r!  SSK J"r#  SSK J$r%  SSK J&r&  SS K'J(r(  SS!K'J)r)  SS"KJ*r*  SS#K+J,r,  SS$K-J.r.  SS%K-J/r/  \(       af  SS&K0J1r1  SS'K2J3r3  SS(K2J4r4  SS)K2J5r5  SS*K2J6r6  SS+K2J7r7  SS,K2J8r8  SS-K2J9r9  SS.K2J:r:  SS/K2J;r;  SS0K<J=r=  SS1K>J?r?  SS2K@JArA  SS3K@JBrB  SS4KCJDrD  SS5KEJFrF  SS6KGJHrH  \/" S75      rI\" S8\S99rJSRS; jrK SS       STS< jjrLSUS= jrM " S> S?5      rN\R                  " \!S@SA/ / / SBQSC9 " SD SE\\!   \SE   \N5      5       rP\R                  " \&SFSG/ / SHQ/ SIQSC9 " SJ S:\\&   \N5      5       rQ " SK SL\\)   \SL   5      rR\SVSM j5       rS\    SWSN j5       rS    SXSO jrS\R                  " \P5          SYSP j5       rU\R                  " \Q5          SZSQ j5       rVg)[    )annotationsN)Any)AsyncIterator)Callable)Dict)	Generator)NoReturn)Optional)overload)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )exc)asyncstartablecontext)GeneratorStartableContext)ProxyComparable)StartableContext)_ensure_sync_result)AsyncResult)AsyncScalarResult   )
inspection)util)
Connection)create_engine)create_pool_from_url)Engine)NestedTransaction)Transaction)ArgumentError)greenlet_spawn)Concatenate)	ParamSpec)CursorResult)_CoreAnyExecuteParams)_CoreSingleExecuteParams)_DBAPIAnyExecuteParams)_ExecuteOptions)CompiledCacheType)CoreExecuteOptionsParameter)Dialect)IsolationLevel)SchemaTranslateMapType)ScalarResult)URL)Pool)PoolProxiedConnection)	_InfoType)
Executable)TypedReturnsRows_P_T)boundAsyncEnginec                (  ^^ UR                  SS5      (       a  [        R                  " S5      eSUS'   UR                  SS5      mT(       a/  UR                  SS5      (       a  [	        S	5      eSUU4S
 jjnX!S'   [        U 40 UD6m[        T5      $ )a  Create a new async engine instance.

Arguments passed to :func:`_asyncio.create_async_engine` are mostly
identical to those passed to the :func:`_sa.create_engine` function.
The specified dialect must be an asyncio-compatible dialect
such as :ref:`dialect-postgresql-asyncpg`.

.. versionadded:: 1.4

:param async_creator: an async callable which returns a driver-level
    asyncio connection. If given, the function should take no arguments,
    and return a new asyncio connection from the underlying asyncio
    database driver; the connection will be wrapped in the appropriate
    structures to be used with the :class:`.AsyncEngine`.   Note that the
    parameters specified in the URL are not applied here, and the creator
    function should use its own connection parameters.

    This parameter is the asyncio equivalent of the
    :paramref:`_sa.create_engine.creator` parameter of the
    :func:`_sa.create_engine` function.

    .. versionadded:: 2.0.16

server_side_cursorsFz}Can't set server_side_cursors for async engine globally; use the connection.stream() method for an async streaming result setT	_is_asyncasync_creatorNcreatorz?Can only specify one of 'async_creator' or 'creator', not both.c                 J   > TR                   R                  R                  T S9$ )N)async_creator_fn)dialectdbapiconnect)r?   sync_engines   U/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/ext/asyncio/engine.pyr@   $create_async_engine.<locals>.creatoro   s,     &&,,44!. 5      returnr   )get	async_excAsyncMethodRequiredpopr#   _create_enginer;   )urlkwr@   r?   rF   s      @@rG   create_async_enginerS   F   s    4 
vv#U++++#
 	

 B{OFF?D1M66)T"" 
	 	  9 ++K{##rI   c                   U R                  5        VVs0 s H,  u  p4UR                  U5      (       d  M  U[        U5      S U_M.     nnnSUS'   UR                  U5        UR	                  S5      n[        U40 UD6$ s  snnf )a  Create a new AsyncEngine instance using a configuration dictionary.

This function is analogous to the :func:`_sa.engine_from_config` function
in SQLAlchemy Core, except that the requested dialect must be an
asyncio-compatible dialect such as :ref:`dialect-postgresql-asyncpg`.
The argument signature of the function is identical to that
of :func:`_sa.engine_from_config`.

.. versionadded:: 1.4.29

NT_coerce_configrQ   )items
startswithlenupdaterO   rS   )configurationprefixkwargskeyvalueoptionsrQ   s          rG   async_engine_from_configr`   |   s      (--//JC>>&! 	"CKME!/  
 !%GNN6
++e
Cs.g..s
   A=A=c                $    SUS'   [        U 40 UD6$ )a>  Create a new async engine instance.

Arguments passed to :func:`_asyncio.create_async_pool_from_url` are mostly
identical to those passed to the :func:`_sa.create_pool_from_url` function.
The specified dialect must be an asyncio-compatible dialect
such as :ref:`dialect-postgresql-asyncpg`.

.. versionadded:: 2.0.10

Tr>   )_create_pool_from_url)rQ   r\   s     rG   create_async_pool_from_urlrc      s     F; ///rI   c                  ,    \ rS rSrSr\SS j5       rSrg)AsyncConnectable   )_slots_dispatch__weakref__c                    [        S5      e)Nzasynchronous events are not implemented at this time.  Apply synchronous listeners to the AsyncEngine.sync_engine or AsyncConnection.sync_connection attributes.)NotImplementedError)clss    rG   _no_async_engine_events(AsyncConnectable._no_async_engine_events   s    !:
 	
rI    NrK   r	   )__name__
__module____qualname____firstlineno__	__slots__classmethodrl   __static_attributes__rn   rI   rG   re   re      s    0I
 
rI   re   z:class:`_engine.Connection`z!:class:`_asyncio.AsyncConnection`)closedinvalidatedrC   default_isolation_level)classmethodsmethods
attributesc                  f   \ rS rSr% SrSr S<   S=S jjrS\S'    S\S	'    \      S>S
 j5       r	 S?   S@S jjr
\SAS j5       rSBS jr\R                  SCS j5       r\R                  SDS j5       rSES jrSES jr S<   SFS jjrSGS jrSHS jrSHS jrSIS jrSIS jr\SSSSSSSSSSS.
                       SJS jj5       r\SKS j5       rSKS jrSLS jrSLS jrSLS  jrSLS! jr  SM       SNS" jjr \ S<SS#.       SOS$ jjj5       r!\ S<SS#.       SPS% jjj5       r!\" S<SS#.       SQS& jjj5       r!\ S<SS#.       SRS' jjj5       r#\ S<SS#.       SSS( jjj5       r# S<SS#.       SSS) jjjr#\ S<SS#.       STS* jjj5       r$\ S<SS#.       SUS+ jjj5       r$ S<SS#.       SUS, jjjr$\ S<SS#.       SVS- jjj5       r%\ S<SS#.       SWS. jjj5       r% S<SS#.       SWS/ jjjr%\ S<SS#.       SXS0 jjj5       r&\ S<SS#.       SYS1 jjj5       r&\" S<SS#.       SZS2 jjj5       r&        S[S3 jr'S\S4 jr(S]S5 jr)\S^S6 j5       r*\S^S7 j5       r+\S_S8 j5       r,\,RZ                  S`S9 j5       r,\S^S: j5       r.S;r/g)aAsyncConnection   a  An asyncio proxy for a :class:`_engine.Connection`.

:class:`_asyncio.AsyncConnection` is acquired using the
:meth:`_asyncio.AsyncEngine.connect`
method of :class:`_asyncio.AsyncEngine`::

    from sqlalchemy.ext.asyncio import create_async_engine

    engine = create_async_engine("postgresql+asyncpg://user:pass@host/dbname")

    async with engine.connect() as conn:
        result = await conn.execute(select(table))

.. versionadded:: 1.4

)enginerF   sync_connectionNr   Optional[Connection]c                ^    Xl         UR                  U l        U R                  U5      U l        g N)r   rF   _assign_proxiedr   )selfasync_enginer   s      rG   __init__AsyncConnection.__init__   s*    
 #'33#33ODrI   r    rF   c                T    [        [        R                  UR                  5      U5      $ r   )r~   r;   _retrieve_proxy_for_targetr   rk   targetadditional_kws      rG   _regenerate_proxy_for_target,AsyncConnection._regenerate_proxy_for_target   s%     226==A6
 	
rI   Fc                   #    U R                   (       a  [        R                  " S5      eU R                  [	        U R
                  R                  5      I Sh  vN 5      U l         U $  N7f)zjStart this :class:`_asyncio.AsyncConnection` object's context
outside of using a Python ``with:`` block.

zconnection is already startedN)r   r   InvalidRequestErrorr   r$   rF   rE   r   is_ctxmanagers     rG   startAsyncConnection.start  sX      ))*IJJ#33 !1!1!9!9:: 
  ;s   AA)A'A)c                .    [         R                  " S5      e)zUNot implemented for async; call
:meth:`_asyncio.AsyncConnection.get_raw_connection`.
zAsyncConnection.connection accessor is not implemented as the attribute may need to reconnect on an invalidated connection.  Use the get_raw_connection() method.)r   r   r   s    rG   
connectionAsyncConnection.connection  s    
 %%3
 	
rI   c                T   #    [        [        U R                  S5      I Sh  vN $  N7f)a  Return the pooled DBAPI-level connection in use by this
:class:`_asyncio.AsyncConnection`.

This is a SQLAlchemy connection-pool proxied connection
which then has the attribute
:attr:`_pool._ConnectionFairy.driver_connection` that refers to the
actual driver connection. Its
:attr:`_pool._ConnectionFairy.dbapi_connection` refers instead
to an :class:`_engine.AdaptedConnection` instance that
adapts the driver connection to the DBAPI protocol.

r   N)r$   getattr_proxiedr   s    rG   get_raw_connection"AsyncConnection.get_raw_connection!  s       $GT]]LIIII   (&(c                .    U R                   R                  $ )a  Return the :attr:`_engine.Connection.info` dictionary of the
underlying :class:`_engine.Connection`.

This dictionary is freely writable for user-defined state to be
associated with the database connection.

This attribute is only available if the :class:`.AsyncConnection` is
currently connected.   If the :attr:`.AsyncConnection.closed` attribute
is ``True``, then accessing this attribute will raise
:class:`.ResourceClosedError`.

.. versionadded:: 1.4.0b2

)r   infor   s    rG   r   AsyncConnection.info1  s      }}!!!rI   c                \    U R                   (       d  U R                  5         U R                   $ r   )r   _raise_for_not_startedr   s    rG   r   AsyncConnection._proxiedC  s#    ##'')###rI   c                >    U R                   (       d   e[        U 5      $ )z1Begin a transaction prior to autobegin occurring.r   AsyncTransactionr   s    rG   beginAsyncConnection.beginI  s    }}}%%rI   c                <    U R                   (       d   e[        U SS9$ )z;Begin a nested transaction and return a transaction handle.T)nestedr   r   s    rG   begin_nestedAsyncConnection.begin_nestedN  s    }}}T22rI   c                Z   #    [        U R                  R                  US9I Sh  vN $  N7f)zInvalidate the underlying DBAPI connection associated with
this :class:`_engine.Connection`.

See the method :meth:`_engine.Connection.invalidate` for full
detail on this method.

)	exceptionN)r$   r   
invalidate)r   r   s     rG   r   AsyncConnection.invalidateS  s-      $MM$$	
 
 	
 
s   "+)+c                \   #    [        U R                  R                  5      I S h  vN $  N7fr   )r$   r   get_isolation_levelr   s    rG   r   #AsyncConnection.get_isolation_levelb  s      #DMM$E$EFFFF   #,*,c                6    U R                   R                  5       $ )z,Return True if a transaction is in progress.)r   in_transactionr   s    rG   r   AsyncConnection.in_transactione  s     }}++--rI   c                6    U R                   R                  5       $ )zIReturn True if a transaction is in progress.

.. versionadded:: 1.4.0b2

)r   in_nested_transactionr   s    rG   r   %AsyncConnection.in_nested_transactionj  s     }}2244rI   c                h    U R                   R                  5       nUb  [        R                  U5      $ g)aO  Return an :class:`.AsyncTransaction` representing the current
transaction, if any.

This makes use of the underlying synchronous connection's
:meth:`_engine.Connection.get_transaction` method to get the current
:class:`_engine.Transaction`, which is then proxied in a new
:class:`.AsyncTransaction` object.

.. versionadded:: 1.4.0b2

N)r   get_transactionr   r   r   transs     rG   r   AsyncConnection.get_transactionr  s0     --/#>>uEErI   c                h    U R                   R                  5       nUb  [        R                  U5      $ g)ai  Return an :class:`.AsyncTransaction` representing the current
nested (savepoint) transaction, if any.

This makes use of the underlying synchronous connection's
:meth:`_engine.Connection.get_nested_transaction` method to get the
current :class:`_engine.Transaction`, which is then proxied in a new
:class:`.AsyncTransaction` object.

.. versionadded:: 1.4.0b2

N)r   get_nested_transactionr   r   r   s     rG   r   &AsyncConnection.get_nested_transaction  s0     446#>>uEErI   .)
compiled_cachelogging_tokenisolation_levelno_parametersstream_resultsmax_row_buffer	yield_perinsertmanyvalues_page_sizeschema_translate_mappreserve_rowcountc       
           #    g 7fr   rn   )r   r   r   r   r   r   r   r   r   r   r   opts               rG   execution_options!AsyncConnection.execution_options  s
         c                   #    g 7fr   rn   r   r   s     rG   r   r     s     FIr   c                r   #    U R                   n[        UR                  40 UD6I Sh  vN nX2L d   eU $  N7f)zSet non-SQL options for the connection which take effect
during execution.

This returns this :class:`_asyncio.AsyncConnection` object with
the new options added.

See :meth:`_engine.Connection.execution_options` for full details
on this method.

N)r   r$   r   )r   r   connc2s       rG   r   r     s=      }}!$"8"8@C@@zz As   &757c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)a  Commit the transaction that is currently in progress.

This method commits the current transaction if one has been started.
If no transaction was started, the method has no effect, assuming
the connection is in a non-invalidated state.

A transaction is begun on a :class:`_engine.Connection` automatically
whenever a statement is first executed, or when the
:meth:`_engine.Connection.begin` method is called.

Nr$   r   commitr   s    rG   r   AsyncConnection.commit  s      T]]11222   #-+-c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)a  Roll back the transaction that is currently in progress.

This method rolls back the current transaction if one has been started.
If no transaction was started, the method has no effect.  If a
transaction was started and the connection is in an invalidated state,
the transaction is cleared using this method.

A transaction is begun on a :class:`_engine.Connection` automatically
whenever a statement is first executed, or when the
:meth:`_engine.Connection.begin` method is called.


Nr$   r   rollbackr   s    rG   r   AsyncConnection.rollback  s      T]]33444r   c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)z}Close this :class:`_asyncio.AsyncConnection`.

This has the effect of also rolling back the transaction if one
is in place.

Nr$   r   closer   s    rG   r   AsyncConnection.close  s      T]]00111r   c                @   #    U R                  5       I Sh  vN   g N7f)zA synonym for :meth:`_asyncio.AsyncConnection.close`.

The :meth:`_asyncio.AsyncConnection.aclose` name is specifically
to support the Python standard library ``@contextlib.aclosing``
context manager function.

.. versionadded:: 2.0.20

Nr   r   s    rG   acloseAsyncConnection.aclose  s      jjls   c                   #    [        U R                  R                  UUUSS9I Sh  vN n[        X@R                  5      I Sh  vN $  N! N7f)zQExecutes a driver-level SQL string and return buffered
:class:`_engine.Result`.

T)_require_awaitN)r$   r   exec_driver_sqlr   r   	statement
parametersr   results        rG   r   AsyncConnection.exec_driver_sql  sP      &MM))
 
 )1E1EFFF
 G!   %AA	AAAAr   c                   g r   rn   r   r   r   r   s       rG   streamAsyncConnection.stream  s     69rI   c                   g r   rn   r   s       rG   r   r     s     7:rI   c          
      #    U R                   R                  (       d  [        R                  " S5      e[	        U R
                  R                  UU[        R                  R                  USS05      SS9I Sh  vN nUR                  R                  (       d   e[        U5      n U7v   [        R                  " UR                  5       5      n[        R                   " U5      I Sh  vN   g Nu N! ["         a     gf = f7f)a  Execute a statement and return an awaitable yielding a
:class:`_asyncio.AsyncResult` object.

E.g.::

    result = await conn.stream(stmt)
    async for row in result:
        print(f"{row}")

The :meth:`.AsyncConnection.stream`
method supports optional context manager use against the
:class:`.AsyncResult` object, as in::

    async with conn.stream(stmt) as result:
        async for row in result:
            print(f"{row}")

In the above pattern, the :meth:`.AsyncResult.close` method is
invoked unconditionally, even if the iterator is interrupted by an
exception throw.   Context manager use remains optional, however,
and the function may be called in either an ``async with fn():`` or
``await fn()`` style.

.. versionadded:: 2.0.0b3 added context manager support


:return: an awaitable object that will yield an
 :class:`_asyncio.AsyncResult` object.

.. seealso::

    :meth:`.AsyncConnection.stream_scalars`

zmCant use `stream` or `stream_scalars` with the current dialect since it does not support server side cursors.r   Tr   r   N)rC   supports_server_side_cursorsr   r   r$   r   executer   
EMPTY_DICT
merge_withcontext_is_server_sider   asynciocreate_taskr   shieldGeneratorExit)r   r   r   r   r   artasks          rG   r   r     s     T ||88))I 
 &MM!!"oo88!$4d#;  
 
 ~~---- 	'H &&rxxz2D..&&&#
" '	  		sH   A6D8C.9,D&C2 +=D(C0)D0D2
C?<D>C??Dc                  #    g 7fr   rn   r   s       rG   r   AsyncConnection.executeZ  
      r   c                  #    g 7fr   rn   r   s       rG   r   r	  c  
       r   c                  #    [        U R                  R                  UUUSS9I Sh  vN n[        X@R                  5      I Sh  vN $  N! N7f)a  Executes a SQL statement construct and return a buffered
:class:`_engine.Result`.

:param object: The statement to be executed.  This is always
 an object that is in both the :class:`_expression.ClauseElement` and
 :class:`_expression.Executable` hierarchies, including:

 * :class:`_expression.Select`
 * :class:`_expression.Insert`, :class:`_expression.Update`,
   :class:`_expression.Delete`
 * :class:`_expression.TextClause` and
   :class:`_expression.TextualSelect`
 * :class:`_schema.DDL` and objects which inherit from
   :class:`_schema.ExecutableDDLElement`

:param parameters: parameters which will be bound into the statement.
 This may be either a dictionary of parameter names to values,
 or a mutable sequence (e.g. a list) of dictionaries.  When a
 list of dictionaries is passed, the underlying statement execution
 will make use of the DBAPI ``cursor.executemany()`` method.
 When a single dictionary is passed, the DBAPI ``cursor.execute()``
 method will be used.

:param execution_options: optional dictionary of execution options,
 which will be associated with the statement execution.  This
 dictionary can provide a subset of the options that are accepted
 by :meth:`_engine.Connection.execution_options`.

:return: a :class:`_engine.Result` object.

Tr   N)r$   r   r   r   r   s        rG   r   r	  l  sN     L &MM!!/
 
 )>>>
 ?r   c                  #    g 7fr   rn   r   s       rG   scalarAsyncConnection.scalar  s
      r   c                  #    g 7fr   rn   r   s       rG   r  r    s
      r   c               ^   #    U R                  XUS9I Sh  vN nUR                  5       $  N7f)aE  Executes a SQL statement construct and returns a scalar object.

This method is shorthand for invoking the
:meth:`_engine.Result.scalar` method after invoking the
:meth:`_engine.Connection.execute` method.  Parameters are equivalent.

:return: a scalar Python value representing the first column of the
 first row returned.

r   N)r   r  r   s        rG   r  r    s8     " ||5F $ 
 
 }}
   -+-c                  #    g 7fr   rn   r   s       rG   scalarsAsyncConnection.scalars  r
  r   c                  #    g 7fr   rn   r   s       rG   r  r    r  r   c               ^   #    U R                  XUS9I Sh  vN nUR                  5       $  N7f)a9  Executes a SQL statement construct and returns a scalar objects.

This method is shorthand for invoking the
:meth:`_engine.Result.scalars` method after invoking the
:meth:`_engine.Connection.execute` method.  Parameters are equivalent.

:return: a :class:`_engine.ScalarResult` object.

.. versionadded:: 1.4.24

r   N)r   r  r   s        rG   r  r    s9     $ ||5F $ 
 
 ~~
r  c                   g r   rn   r   s       rG   stream_scalarsAsyncConnection.stream_scalars  s     <?rI   c                   g r   rn   r   s       rG   r  r    s     =@rI   c                 #    U R                  XUS9 ISh  vN nUR                  5       7v   SSS5      ISh  vN   g N( N! , ISh  vN  (       d  f       g= f7f)a  Execute a statement and return an awaitable yielding a
:class:`_asyncio.AsyncScalarResult` object.

E.g.::

    result = await conn.stream_scalars(stmt)
    async for scalar in result:
        print(f"{scalar}")

This method is shorthand for invoking the
:meth:`_engine.AsyncResult.scalars` method after invoking the
:meth:`_engine.Connection.stream` method.  Parameters are equivalent.

The :meth:`.AsyncConnection.stream_scalars`
method supports optional context manager use against the
:class:`.AsyncScalarResult` object, as in::

    async with conn.stream_scalars(stmt) as result:
        async for scalar in result:
            print(f"{scalar}")

In the above pattern, the :meth:`.AsyncScalarResult.close` method is
invoked unconditionally, even if the iterator is interrupted by an
exception throw.  Context manager use remains optional, however,
and the function may be called in either an ``async with fn():`` or
``await fn()`` style.

.. versionadded:: 2.0.0b3 added context manager support

:return: an awaitable object that will yield an
 :class:`_asyncio.AsyncScalarResult` object.

.. versionadded:: 1.4.24

.. seealso::

    :meth:`.AsyncConnection.stream`

r   N)r   r  r   s        rG   r  r    sR     ` ;;5F  
 
..""
 
 
 
 
 
sA   AA AAAAAAA
AAAc                T   #    [        XR                  /UQ7SS0UD6I Sh  vN $  N7f)a  Invoke the given synchronous (i.e. not async) callable,
passing a synchronous-style :class:`_engine.Connection` as the first
argument.

This method allows traditional synchronous SQLAlchemy functions to
run within the context of an asyncio application.

E.g.::

    def do_something_with_core(conn: Connection, arg1: int, arg2: str) -> str:
        """A synchronous function that does not require awaiting

        :param conn: a Core SQLAlchemy Connection, used synchronously

        :return: an optional return value is supported

        """
        conn.execute(some_table.insert().values(int_col=arg1, str_col=arg2))
        return "success"


    async def do_something_async(async_engine: AsyncEngine) -> None:
        """an async function that uses awaiting"""

        async with async_engine.begin() as async_conn:
            # run do_something_with_core() with a sync-style
            # Connection, proxied into an awaitable
            return_code = await async_conn.run_sync(
                do_something_with_core, 5, "strval"
            )
            print(return_code)

This method maintains the asyncio event loop all the way through
to the database connection by running the given callable in a
specially instrumented greenlet.

The most rudimentary use of :meth:`.AsyncConnection.run_sync` is to
invoke methods such as :meth:`_schema.MetaData.create_all`, given
an :class:`.AsyncConnection` that needs to be provided to
:meth:`_schema.MetaData.create_all` as a :class:`_engine.Connection`
object::

    # run metadata.create_all(conn) with a sync-style Connection,
    # proxied into an awaitable
    with async_engine.begin() as conn:
        await conn.run_sync(metadata.create_all)

.. note::

    The provided callable is invoked inline within the asyncio event
    loop, and will block on traditional IO calls.  IO within this
    callable should only call into SQLAlchemy's asyncio database
    APIs which will be properly adapted to the greenlet context.

.. seealso::

    :meth:`.AsyncSession.run_sync`

    :ref:`session_run_sync`

r   FN)r$   r   )r   fnargrR   s       rG   run_syncAsyncConnection.run_sync3  s>     H $
 #
49
=?
 
 	
 
r   c                >    U R                  5       R                  5       $ r   )r   	__await__r   s    rG   r$  AsyncConnection.__await__{  s    zz|%%''rI   c                   #    [         R                  " U R                  5       5      n[         R                  " U5      I S h  vN   g  N7fr   )r  r  r   r  )r   type_r^   	tracebackr  s        rG   	__aexit__AsyncConnection.__aexit__~  s-     ""4::<0nnT"""s   >A AAc                .    U R                   R                  $ )zReturn True if this connection is closed.

.. container:: class_bases

    Proxied for the :class:`_engine.Connection` class
    on behalf of the :class:`_asyncio.AsyncConnection` class.

)r   rw   r   s    rG   rw   AsyncConnection.closed  s     }}###rI   c                .    U R                   R                  $ )a$  Return True if this connection was invalidated.

.. container:: class_bases

    Proxied for the :class:`_engine.Connection` class
    on behalf of the :class:`_asyncio.AsyncConnection` class.

This does not indicate whether or not the connection was
invalidated at the pool level, however


)r   rx   r   s    rG   rx   AsyncConnection.invalidated  s     }}(((rI   c                .    U R                   R                  $ )zvProxy for the :attr:`_engine.Connection.dialect` attribute
on behalf of the :class:`_asyncio.AsyncConnection` class.

r   rC   r   s    rG   rC   AsyncConnection.dialect       }}$$$rI   c                $    XR                   l        g r   r0  r   attrs     rG   rC   r1         $rI   c                .    U R                   R                  $ )a   The initial-connection time isolation level associated with the
:class:`_engine.Dialect` in use.

.. container:: class_bases

    Proxied for the :class:`_engine.Connection` class
    on behalf of the :class:`_asyncio.AsyncConnection` class.

This value is independent of the
:paramref:`.Connection.execution_options.isolation_level` and
:paramref:`.Engine.execution_options.isolation_level` execution
options, and is determined by the :class:`_engine.Dialect` when the
first connection is created, by performing a SQL query against the
database for the current isolation level before any additional commands
have been emitted.

Calling this accessor does not invoke any new SQL queries.

.. seealso::

    :meth:`_engine.Connection.get_isolation_level`
    - view current actual isolation level

    :paramref:`_sa.create_engine.isolation_level`
    - set per :class:`_engine.Engine` isolation level

    :paramref:`.Connection.execution_options.isolation_level`
    - set per :class:`_engine.Connection` isolation level


)r   ry   r   s    rG   ry   'AsyncConnection.default_isolation_level  s    D }}444rI   )r   r   rF   r   )r   r;   r   r   )r   r   r   r   rK   r~   F)r   boolrK   r~   ro   rK   r4   )rK   r5   )rK   r   )rK   r   )r   zOptional[BaseException]rK   None)rK   r/   rK   r:  )rK   zOptional[AsyncTransaction])r   Optional[CompiledCacheType]r   strr   r/   r   r:  r   r:  r   intr   r@  r   r@  r    Optional[SchemaTranslateMapType]r   r:  r   r   rK   r~   )r   r   rK   r~   rK   r<  )NN)r   r?  r   z Optional[_DBAPIAnyExecuteParams]r   %Optional[CoreExecuteOptionsParameter]rK   CursorResult[Any])r   TypedReturnsRows[_T]r   Optional[_CoreAnyExecuteParams]r   rC  rK   z*GeneratorStartableContext[AsyncResult[_T]])r   r6   r   rF  r   rC  rK   z+GeneratorStartableContext[AsyncResult[Any]])r   r6   r   rF  r   rC  rK   zAsyncIterator[AsyncResult[Any]])r   rE  r   rF  r   rC  rK   zCursorResult[_T])r   r6   r   rF  r   rC  rK   rD  )r   TypedReturnsRows[Tuple[_T]]r   "Optional[_CoreSingleExecuteParams]r   rC  rK   zOptional[_T])r   r6   r   rH  r   rC  rK   r   )r   rG  r   rF  r   rC  rK   zScalarResult[_T])r   r6   r   rF  r   rC  rK   zScalarResult[Any])r   rG  r   rH  r   rC  rK   z0GeneratorStartableContext[AsyncScalarResult[_T]])r   r6   r   rH  r   rC  rK   z1GeneratorStartableContext[AsyncScalarResult[Any]])r   r6   r   rH  r   rC  rK   z%AsyncIterator[AsyncScalarResult[Any]])r  z)Callable[Concatenate[Connection, _P], _T]r   z_P.argsrR   z	_P.kwargsrK   r9   )rK   z%Generator[Any, None, AsyncConnection]r'  r   r^   r   r(  r   rK   r<  rJ   rK   r.   r5  r.   rK   r<  )0rp   rq   rr   rs   __doc__rt   r   __annotations__ru   r   r   propertyr   r   r   ro_non_memoized_propertyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r!  r$  r)  rw   rx   rC   setterry   rv   rn   rI   rG   r~   r~      s"   $,I 15E!E .E *)	 
 

25
	
 
 %*!	 
 
J  
""" #"" 
""$ #$
&
3 48
0
	
G.
5&&  7: *-#$!*-AD"' 4 	
 (     %( ?    
   I I"35 2
 8<CG	GG 5G A	G
 
G*  7;9
 DH9'9 49
 A9 
49 9  7;:
 DH:: 4:
 A: 
5: :  7;@'
 DH@'@' 4@'
 A@' 
)@' @'D  7;
 DH' 4
 A 
   7; 
 DH   4 
 A  
    7;-?
 DH-?-? 4-?
 A-? 
-?^  :>
 DH. 7
 A 
   :>
 DH 7
 A 
  :>
 DH 7
 A 
,  7;
 DH. 4
 A 
   7; 
 DH   4 
 A  
    7; 
 DH   4 
 A  
 .  :>?
 DH?.? 7?
 A? 
:? ?  :>@
 DH@@ 7@
 A@ 
;@ @  :>2#
 DH2#2# 72#
 A2# 
/2# 2#hF
5F
 F
 	F

 
F
P(# 
$ 
$ ) )  % % ^^% % !5 !5rI   r~   z:class:`_engine.Engine`z:class:`_asyncio.AsyncEngine`)clear_compiled_cacheupdate_execution_optionsget_execution_options)rQ   poolrC   r   namedriverechoc                  z   \ rS rSr% SrSr\rS\S'   S\S'    S#S jr	\
R                  S$S j5       r\      S%S	 j5       r\R                   S&S
 j5       rS'S jrS(S jr\SSSSSS.             S)S jj5       r\S*S j5       rS*S jrS+S,S jjrS-S jrS.S jrS/S jr\S0S j5       r\R8                  S1S j5       r\S2S j5       r\R8                  S3S j5       r\S4S j5       r\R8                  S5S j5       r\S6S j5       r\S6S j5       r \S6S j5       r!\S6S j5       r"\"R8                  S7S  j5       r"S!r#g")8r;   i  a9  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

rF   zType[AsyncConnection]_connection_clsr    c                    UR                   R                  (       d/  [        R                  " SUR                   R                  < S35      eU R                  U5      U l        g )NzFThe asyncio extension requires an async driver to be used. The loaded z is not async.)rC   is_asyncr   r   rV  r   rF   )r   rF   s     rG   r   AsyncEngine.__init__  sX    ""++)))1188;>K   //<rI   c                    U R                   $ r   rF   r   s    rG   r   AsyncEngine._proxied  s    rI   c                    [        U5      $ r   )r;   r   s      rG   r   (AsyncEngine._regenerate_proxy_for_target  s     6""rI   c               6  #    U R                  5       nU ISh  vN   UR                  5        ISh  vN   U7v   SSS5      ISh  vN   SSS5      ISh  vN   g NC N, N! , ISh  vN  (       d  f       N.= f N%! , ISh  vN  (       d  f       g= f7f)ap  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)"))

N)rE   r   )r   r   s     rG   r   AsyncEngine.begin  sL      ||~4zz||
 $| 44#||| 444s   BABA?AA?A#A?A!A?BA=BA?!A?#A:	)A,*A:	6A?=B?BBBBc                $    U R                  U 5      $ )a  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.

)rY  r   s    rG   rE   AsyncEngine.connect.  s      ##D))rI   c                \   #    [        U R                  R                  5      I Sh  vN $  N7f)zgReturn a "raw" DBAPI connection from the connection pool.

.. seealso::

    :ref:`dbapi_connections`

N)r$   rF   raw_connectionr   s    rG   rg  AsyncEngine.raw_connection@  s$      $D$4$4$C$CDDDDr   .)r   r   r   r   r   c                   g r   rn   )r   r   r   r   r   r   r   s          rG   r   AsyncEngine.execution_optionsJ  s     rI   c                    g r   rn   r   s     rG   r   rj  V  s    <?rI   c                L    [        U R                  R                  " S0 UD65      $ )zReturn 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.

rn   )r;   rF   r   r   s     rG   r   rj  Y  s#     4++==DDEErI   c                \   #    [        U R                  R                  US9I Sh  vN   g N7f)a  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`

r   N)r$   rF   dispose)r   r   s     rG   rn  AsyncEngine.disposee  s#     . T--55UCCCs   ",*,c                6    U R                   R                  5       $ )a  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.compiled_cache` parameter.

.. versionadded:: 1.4


)r   rQ  r   s    rG   rQ   AsyncEngine.clear_compiled_cache  s    $ }}1133rI   c                :    U R                   R                  " S0 UD6$ )a8  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`


rn   )r   rR  r   s     rG   rR  $AsyncEngine.update_execution_options  s    0 }}55<<<rI   c                6    U R                   R                  5       $ )a  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`

)r   rS  r   s    rG   rS  !AsyncEngine.get_execution_options  s      }}2244rI   c                .    U R                   R                  $ )zjProxy for the :attr:`_engine.Engine.url` attribute
on behalf of the :class:`_asyncio.AsyncEngine` class.

r   rQ   r   s    rG   rQ   AsyncEngine.url  s     }}   rI   c                $    XR                   l        g r   rw  r4  s     rG   rQ   rx    s     rI   c                .    U R                   R                  $ )zkProxy for the :attr:`_engine.Engine.pool` attribute
on behalf of the :class:`_asyncio.AsyncEngine` class.

r   rT  r   s    rG   rT  AsyncEngine.pool  s     }}!!!rI   c                $    XR                   l        g r   r{  r4  s     rG   rT  r|        !rI   c                .    U R                   R                  $ )znProxy for the :attr:`_engine.Engine.dialect` attribute
on behalf of the :class:`_asyncio.AsyncEngine` class.

r0  r   s    rG   rC   AsyncEngine.dialect  r2  rI   c                $    XR                   l        g r   r0  r4  s     rG   rC   r    r6  rI   c                .    U R                   R                  $ )a  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.


)r   r   r   s    rG   r   AsyncEngine.engine  s     }}###rI   c                .    U R                   R                  $ )zString 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.


)r   rU  r   s    rG   rU  AsyncEngine.name  s     }}!!!rI   c                .    U R                   R                  $ )zDriver 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.


)r   rV  r   s    rG   rV  AsyncEngine.driver
  s     }}###rI   c                .    U R                   R                  $ )a  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``.

r   rW  r   s    rG   rW  AsyncEngine.echo  s    " }}!!!rI   c                $    XR                   l        g r   r  r4  s     rG   rW  r  ,  r~  rI   r^  N)rF   r    )rK   r    )r   r    r   r   rK   r;   )rK   zAsyncIterator[AsyncConnection])rK   r~   r;  )r   r>  r   r?  r   r/   r   r@  r   rA  r   r   rK   r;   )r   r   rK   r;   )T)r   r:  rK   r<  rB  )r   r   rK   r<  )rK   r+   )rK   r2   )r5  r2   rK   r<  )rK   r3   )r5  r3   rK   r<  rJ  rK  rJ   )r5  r   rK   r<  )$rp   rq   rr   rs   rL  rt   r~   rY  rM  r   r   rO  r   ru   r   
contextlibasynccontextmanagerr   rE   rg  r   r   rn  rQ  rR  rS  rN  rQ   rP  rT  rC   r   rU  rV  rW  rv   rn   rI   rG   r;   r;     s   $ I-<O*<= 
""  #  ##.1#	# #
 ## $(*$E  7: *-*-AD	 4	 		
 (	 %(	 ?	 	 
	 	 ? ?
FD<4(=45$ ! ! 	ZZ! ! " " 
[[" " % % ^^% % $ $  " " $ $ " "$ 
[[" "rI   c                      \ rS rSr% SrSrS\S'   S\S'   S\S	'   SSS
 jjr\      SS j5       r	\
R                  SS j5       r\SS j5       r\SS j5       rSS jrSS jrSS jrSSS jjrSS jrSrg)r   i3  z4An asyncio proxy for a :class:`_engine.Transaction`.r   sync_transactionr   zOptional[Transaction]r  r~   r   r:  r   c                *    Xl         S U l        X l        g r   r  )r   r   r   s      rG   r   AsyncTransaction.__init__>  s    $ $rI   c                    UR                   nUn[        U[        5      n[        R	                  U5      nUc   eU R                  U 5      nXgl         UR                  U5      Ul        XWl        U$ r   )	r   
isinstancer!   r~   r   __new__r   r  r   )rk   r   r   r   r  r   async_connectionobjs           rG   r   -AsyncTransaction._regenerate_proxy_for_targetC  su     !++!F$56*EE
  +++kk#)"223CD

rI   c                \    U R                   (       d  U R                  5         U R                   $ r   )r  r   r   s    rG   r   AsyncTransaction._proxiedV  s#    $$'')$$$rI   c                .    U R                   R                  $ r   )r   is_validr   s    rG   r  AsyncTransaction.is_valid\  s    }}%%%rI   c                .    U R                   R                  $ r   )r   	is_activer   s    rG   r  AsyncTransaction.is_active`  s    }}&&&rI   c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)a  Close this :class:`.AsyncTransaction`.

If this transaction is the base transaction in a begin/commit
nesting, the transaction will rollback().  Otherwise, the
method returns.

This is used to cancel a Transaction without affecting the scope of
an enclosing transaction.

Nr   r   s    rG   r   AsyncTransaction.closed  s      T]]00111r   c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)z*Roll back this :class:`.AsyncTransaction`.Nr   r   s    rG   r   AsyncTransaction.rollbackq  s     T]]33444r   c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)z'Commit this :class:`.AsyncTransaction`.Nr   r   s    rG   r   AsyncTransaction.commitu  s      T]]11222r   c                @  #    U R                  [        U R                  (       a   U R                  R                  R
                  OU R                  R                  R                  5      I Sh  vN 5      U l        U(       a  U R                  R                  5         U $  N07f)zkStart this :class:`_asyncio.AsyncTransaction` object's context
outside of using a Python ``with:`` block.

N)	r   r$   r   r   r   r   r   r  	__enter__r   s     rG   r   AsyncTransaction.startz  sw      !% 4 4 ;; ((55__--33 !
 !!++-s   A)B+B,1Bc                b   #    [        U R                  R                  XU5      I S h  vN   g  N7fr   )r$   r   __exit__)r   r'  r^   r(  s       rG   r)  AsyncTransaction.__aexit__  s!     T]]33U9MMMs   %/-/)r   r   r  Nr9  )r   r~   r   r:  )r   r"   r   r   rK   r   )rK   r"   r=  rB  )r   r:  rK   r   rI  )rp   rq   rr   rs   rL  rt   rM  r   ru   r   r   rO  r   rN  r  r  r   r   r   r   r)  rv   rn   rI   rG   r   r   3  s     ?<I++L
  36	 $ 
""% #%
 & & ' '253
"NrI   r   c                    g r   rn   r   s    rG   _get_sync_engine_or_connectionr    s    ILrI   c                    g r   rn   r  s    rG   r  r    s     rI   c                    [        U [        5      (       a  U R                  $  U R                  $ ! [         a  n[
        R                  " SU -  5      UeS nAff = f)NzAsyncEngine expected, got %r)r  r~   r   rF   AttributeErrorr   r#   )r   es     rG   r  r    s\     ,00$$$''' *\9
	s   / 
AAAc                ,    [         R                  " SSS9e)NzInspection on an AsyncConnection is currently not supported. Please use ``run_sync`` to pass a callable where it's possible to call ``inspect`` on the passed connection.xd3scoder   NoInspectionAvailablesubjects    rG   _no_insp_for_async_conn_yetr    s!     
#
#	8 	 rI   c                ,    [         R                  " SSS9e)NzInspection on an AsyncEngine is currently not supported. Please obtain a connection then use ``conn.run_sync`` to pass a callable where it's possible to call ``inspect`` on the passed connection.r  r  r  r  s    rG   _no_insp_for_async_engine_xyetr    s!     
#
#	  rI   )rQ   Union[str, URL]rR   r   rK   r;   )zsqlalchemy.)rZ   zDict[str, Any]r[   r?  r\   r   rK   r;   )rQ   r  r\   r   rK   r3   )r   r;   rK   r    )r   r~   rK   r   )r   z#Union[AsyncEngine, AsyncConnection]rK   zUnion[Engine, Connection])r  r~   rK   r	   )r  r;   rK   r	   )W
__future__r   r  r  typingr   r   r   r   r   r	   r
   r   r   r   r   r   r    r   rM   baser   r   r   r   r   r   r   r   r   r   r   r   r   rP   r   rb   r    engine.baser!   r"   r#   util.concurrencyr$   util.typingr%   r&   engine.cursorr'   engine.interfacesr(   r)   r*   r+   r,   r-   r.   r/   r0   engine.resultr1   
engine.urlr2   rT  r3   r4   sql._typingr5   sql.baser6   sql.selectabler7   r8   r9   rS   r`   rc   re   create_proxy_methodsr~   r;   r   r  	_inspectsr  r  rn   rI   rG   <module>r     s`   #                   ' + ! " '  %      5 C  , &   . & $-:=;46@,3;-!-(&2t_T3$n 2?/!/+./JM//20	
 	
 !'W5J&'W5W5x 
#
 NI"/&)+; I"I"\
YNK "23E"FYNx 
 L 
 L 
! 

5 o& ' k"			 #	rI   