
    ,h              	      p   S SK J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+  \(       a  SS%KJ,r,  SS&KJ-r-  SS'KJ.r.  SS(KJ/r/  SS)KJ0r0  SS*KJ1r1  SS+KJ2r2  SS,KJ3r3  SS-KJ4r4  SS.K5J6r6  SS/K5J7r7  SS0K8J9r9  SS1K:J;r;  SS2K:J<r<  SS3K:J=r=  SS4K>J?r?  SS5K@JArA  SS6KBJCrC  SS7KBJDrD  SS8KBJErE  SS9KBJFrF  SS:KBJGrG  SS;KHJIrI  SS<KJJKrK  SS=KLJMrM  SS>KNJOrO  SS?KPJQrQ  SS@KPJRrR  \SA   rS\+" SB5      rT\" SC\SD9rU\R                  " SESF05      rW\R                  " SGSF05      rX " SH SI5      rY\R                  " \#SJSKSLSM// SNQ/ SOQSP9 " SQ SR\\#   5      5       r[\" SSSRSD9r\ " ST SU\	\\   5      r] " SV SW\	\\   5      r^ " SX SY\\$   \SY   5      r_S]SZ jr`S^S[ jraS_S\ jr \a\&lb        g)`    )annotationsN)Any)	Awaitable)Callable)cast)Dict)Generic)Iterable)Iterator)NoReturn)Optional)overload)Sequence)Tuple)Type)TYPE_CHECKING)TypeVar)Union   )engine)ReversibleProxy)StartableContext)_ensure_sync_result)AsyncResult)AsyncScalarResult   )utilclose_all_sessions)object_session)Session)SessionTransaction)state)greenlet_spawn)Concatenate)	ParamSpec)AsyncConnection)AsyncEngine)
Connection)CursorResult)Engine)Result)Row)
RowMapping)ScalarResult)_CoreAnyExecuteParams)CoreExecuteOptionsParameter)
dispatcher)_IdentityKeyType)_O)OrmExecuteOptionsParameter)IdentityMap)	ORMOption)_BindArguments)_EntityBindKey)_PKIdentityArgument)_SessionBind)_SessionBindKey)	_InfoType)
Executable)
UpdateBase)ClauseElement)ForUpdateParameter)TypedReturnsRows)r(   r'   _P_T)boundprebuffer_rowsTstream_resultsc                  @    \ rS rSrSr " S S5      r\SS j5       rSrg)	
AsyncAttrsU   a  Mixin class which provides an awaitable accessor for all attributes.

E.g.::

    from __future__ import annotations

    from typing import List

    from sqlalchemy import ForeignKey
    from sqlalchemy import func
    from sqlalchemy.ext.asyncio import AsyncAttrs
    from sqlalchemy.orm import DeclarativeBase
    from sqlalchemy.orm import Mapped
    from sqlalchemy.orm import mapped_column
    from sqlalchemy.orm import relationship


    class Base(AsyncAttrs, DeclarativeBase):
        pass


    class A(Base):
        __tablename__ = "a"

        id: Mapped[int] = mapped_column(primary_key=True)
        data: Mapped[str]
        bs: Mapped[List[B]] = relationship()


    class B(Base):
        __tablename__ = "b"
        id: Mapped[int] = mapped_column(primary_key=True)
        a_id: Mapped[int] = mapped_column(ForeignKey("a.id"))
        data: Mapped[str]

In the above example, the :class:`_asyncio.AsyncAttrs` mixin is applied to
the declarative ``Base`` class where it takes effect for all subclasses.
This mixin adds a single new attribute
:attr:`_asyncio.AsyncAttrs.awaitable_attrs` to all classes, which will
yield the value of any attribute as an awaitable. This allows attributes
which may be subject to lazy loading or deferred / unexpiry loading to be
accessed such that IO can still be emitted::

    a1 = (await async_session.scalars(select(A).where(A.id == 5))).one()

    # use the lazy loader on ``a1.bs`` via the ``.awaitable_attrs``
    # interface, so that it may be awaited
    for b1 in await a1.awaitable_attrs.bs:
        print(b1)

The :attr:`_asyncio.AsyncAttrs.awaitable_attrs` performs a call against the
attribute that is approximately equivalent to using the
:meth:`_asyncio.AsyncSession.run_sync` method, e.g.::

    for b1 in await async_session.run_sync(lambda sess: a1.bs):
        print(b1)

.. versionadded:: 2.0.13

.. seealso::

    :ref:`asyncio_orm_avoid_lazyloads`

c                  ,    \ rS rSrSrSS jrSS jrSrg)	AsyncAttrs._AsyncAttrGetitem   	_instancec                    Xl         g NrN   )selfrN   s     V/var/www/auris/envauris/lib/python3.13/site-packages/sqlalchemy/ext/asyncio/session.py__init__%AsyncAttrs._AsyncAttrGetitem.__init__   s    &N    c                8    [        [        U R                  U5      $ rP   )r$   getattrrN   )rR   names     rS   __getattr__(AsyncAttrs._AsyncAttrGetitem.__getattr__   s    !'4>>4@@rV   rQ   N)rN   r   )rY   strreturnzAwaitable[Any])__name__
__module____qualname____firstlineno__	__slots__rT   rZ   __static_attributes__ rV   rS   _AsyncAttrGetitemrL      s    		'	ArV   re   c                ,    [         R                  U 5      $ )a&  provide a namespace of all attributes on this object wrapped
as awaitables.

e.g.::


    a1 = (await async_session.scalars(select(A).where(A.id == 5))).one()

    some_attribute = await a1.awaitable_attrs.some_deferred_attribute
    some_collection = await a1.awaitable_attrs.some_collection

)rI   re   rR   s    rS   awaitable_attrsAsyncAttrs.awaitable_attrs   s     ++D11rV   rd   N)r]   rL   )	r^   r_   r`   ra   __doc__re   propertyrh   rc   rd   rV   rS   rI   rI   U   s(    ?BA A 2 2rV   rI   z:class:`_orm.Session`z:class:`_asyncio.AsyncSession`r    identity_key)__contains____iter__addadd_allexpire
expire_allexpungeexpunge_allis_modifiedin_transactionin_nested_transaction)dirtydeletednewidentity_map	is_active	autoflushno_autoflushinfo)classmethodsmethods
attributesc                  .	   \ rS rSr% SrSrS\S'    SUSSS.       SVS	 jjjr\r	S
\S'    S\S'    \
SWS j5       r  SX       SYS jjr        SZS jr\ SU\R                   SSSS.             S[S jjj5       r\ SU\R                   SSSS.             S\S jjj5       r\ SU\R                   SSSS.             S]S jjj5       r SU\R                   SS.           S^S jjjr\ SU\R                   SS.           S_S jjj5       r\ SU\R                   SS.           S`S jjj5       r SU\R                   SS.           S`S jjjr\ SU\R                   SS.           SaS jjj5       r\ SU\R                   SS.           SbS jjj5       r SU\R                   SS.           SbS jjjrSSSS\R                   S.               ScS jjrSSSS\R                   S.               SdS jjr\ SU\R                   SS.           SeS  jjj5       r\ SU\R                   SS.           SfS! jjj5       r SU\R                   SS.           SfS" jjjr\ SU\R                   SS.           SgS# jjj5       r\ SU\R                   SS.           ShS$ jjj5       r SU\R                   SS.           ShS% jjjrSiS& jrSSS'.       SjS( jjrSUSkS) jjrSlS* jrSlS+ jr   Sm         SnS, jjr  SX       SoS- jjrSpS. jrSpS/ jr SqS0 jr!SqS1 jr"SqS2 jr#SqS3 jr$SqS4 jr%SqS5 jr&\
\RN                  " S6S75      SqS8 j5       5       r(SrS9 jr)SsS: jr*StS; jr+SuS< jr,SvS= jr-SwSxS> jjr.SyS? jr/ SU     SzS@ jjr0SqSA jr1SiSB jr2SqSC jr3 Sw     S{SD jjr4S|SE jr5S|SF jr6\7S}SG j5       r8\7S}SH j5       r9\7S}SI j5       r:\7S~SJ j5       r;\;Rx                  SSK j5       r;\7S}SL j5       r=\7S|SM j5       r>\>Rx                  SSN j5       r>\7S}SO j5       r?\7S}SP j5       r@\
SSQ j5       rA\
  SXSSSSR.           SSS jjj5       rBSTrCg)AsyncSession   a  Asyncio version of :class:`_orm.Session`.

The :class:`_asyncio.AsyncSession` is a proxy for a traditional
:class:`_orm.Session` instance.

The :class:`_asyncio.AsyncSession` is **not safe for use in concurrent
tasks.**.  See :ref:`session_faq_threadsafe` for background.

.. versionadded:: 1.4

To use an :class:`_asyncio.AsyncSession` with custom :class:`_orm.Session`
implementations, see the
:paramref:`_asyncio.AsyncSession.sync_session_class` parameter.


Tzdispatcher[Session]dispatchN)bindssync_session_classr   c               `   S=pVU(       a  Xl         [        R                  " U5      nU(       a?  X l        UR	                  5        VVs0 s H  u  pxU[        R                  " U5      _M     nnnU(       a  X0l        U R                  U R
                  " SXVS.UD65      =U l        U l        gs  snnf )a}  Construct a new :class:`_asyncio.AsyncSession`.

All parameters other than ``sync_session_class`` are passed to the
``sync_session_class`` callable directly to instantiate a new
:class:`_orm.Session`. Refer to :meth:`_orm.Session.__init__` for
parameter documentation.

:param sync_session_class:
  A :class:`_orm.Session` subclass or other callable which will be used
  to construct the :class:`_orm.Session` which will be proxied. This
  parameter may be used to provide custom :class:`_orm.Session`
  subclasses. Defaults to the
  :attr:`_asyncio.AsyncSession.sync_session_class` class-level
  attribute.

  .. versionadded:: 1.4.24

N)bindr   rd   )	r   r   _get_sync_engine_or_connectionr   itemsr   _assign_proxiedsync_session_proxied)	rR   r   r   r   kw	sync_bind
sync_bindskeybs	            rS   rT   AsyncSession.__init__   s    4 "&%	I==dCIJ $kkm+FC V::1==+  
 &8#,0,@,@##KKK-
 	
DMs   #B*zType[Session]r!   r   c                    [        S5      e)Nztasynchronous events are not implemented at this time.  Apply synchronous listeners to the AsyncSession.sync_session.)NotImplementedErrorclss    rS   _no_async_engine_events$AsyncSession._no_async_engine_events0  s    !F
 	
rV   c                `   #    [        U R                  R                  UUUS9I Sh  vN   g N7f)a}  Expire and refresh the attributes on the given instance.

A query will be issued to the database and all attributes will be
refreshed with their current database value.

This is the async version of the :meth:`_orm.Session.refresh` method.
See that method for a complete description of all options.

.. seealso::

    :meth:`_orm.Session.refresh` - main documentation for refresh

)attribute_nameswith_for_updateN)r$   r   refresh)rR   instancer   r   s       rS   r   AsyncSession.refresh7  s1     ( %%++	
 	
 	
   $.,.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:`_orm.Session` as the first
argument.

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

E.g.::

    def some_business_method(session: Session, param: str) -> str:
        """A synchronous function that does not require awaiting

        :param session: a SQLAlchemy Session, used synchronously

        :return: an optional return value is supported

        """
        session.add(MyObject(param=param))
        session.flush()
        return "success"


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

        with AsyncSession(async_engine) as async_session:
            # run some_business_method() with a sync-style
            # Session, proxied into an awaitable
            return_code = await async_session.run_sync(
                some_business_method, param="param1"
            )
            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.

.. tip::

    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::

    :class:`.AsyncAttrs`  - a mixin for ORM mapped classes that provides
    a similar feature more succinctly on a per-attribute basis

    :meth:`.AsyncConnection.run_sync`

    :ref:`session_run_sync`
_require_awaitFN)r$   r   )rR   fnargr   s       rS   run_syncAsyncSession.run_syncR  s@     x $!!
$'
8=
AC
 
 	
 
s   (&()execution_optionsbind_arguments_parent_execute_state
_add_eventc                  #    g 7frP   rd   rR   	statementparamsr   r   r   r   s          rS   executeAsyncSession.execute  s
         c                  #    g 7frP   rd   r   s          rS   r   r     s
       r   c                  #    g 7frP   rd   r   s          rS   r   r     s
      r   )r   r   c                 #    U(       a*  [         R                  " U5      R                  [        5      nO[        n[	        U R
                  R                  U4UUUS.UD6I Sh  vN n[        X`R                  5      I Sh  vN $  N! N7f)zExecute a statement and return a buffered
:class:`_engine.Result` object.

.. seealso::

    :meth:`_orm.Session.execute` - main documentation for execute

r   r   r   N)r   immutabledictunion_EXECUTE_OPTIONSr$   r   r   r   rR   r   r   r   r   r   results          rS   r   r     s     $  $ 2 23D E K K ! !1%%%
 /)
 
 
 )>>>
 ?s$   A B"B#B?B BBc                  #    g 7frP   rd   rR   r   r   r   r   r   s         rS   scalarAsyncSession.scalar  s
      r   c                  #    g 7frP   rd   r   s         rS   r   r     s
      r   c                  #    U(       a*  [         R                  " U5      R                  [        5      nO[        n[	        U R
                  R                  U4UUUS.UD6I Sh  vN $  N7f)zExecute a statement and return a scalar result.

.. seealso::

    :meth:`_orm.Session.scalar` - main documentation for scalar

r   N)r   r   r   r   r$   r   r   r   s         rS   r   r     su     "  $ 2 23D E K K ! !1#$$
 /)
 
 
 	
 
s   A A)"A'#A)c                  #    g 7frP   rd   r   s         rS   scalarsAsyncSession.scalars  
      r   c                  #    g 7frP   rd   r   s         rS   r   r     s
       r   c               l   #    U R                   " U4UUUS.UD6I Sh  vN nUR                  5       $  N7f)a  Execute a statement and return scalar results.

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

.. versionadded:: 1.4.24 Added :meth:`_asyncio.AsyncSession.scalars`

.. versionadded:: 1.4.26 Added
   :meth:`_asyncio.async_scoped_session.scalars`

.. seealso::

    :meth:`_orm.Session.scalars` - main documentation for scalars

    :meth:`_asyncio.AsyncSession.stream_scalars` - streaming version

r   N)r   r   r   s          rS   r   r   &  sI     4 ||
/)	

 
 
 ~~
   424Foptionspopulate_existingr   identity_tokenr   c               z   #    [        [        SU R                  R                  5      UUUUUUUS9I Sh  vN $  N7f)zReturn an instance based on the given primary key identifier,
or ``None`` if not found.

.. seealso::

    :meth:`_orm.Session.get` - main documentation for get


Callable[..., _O]r   N)r$   r   r   getrR   entityidentr   r   r   r   r   s           rS   r   AsyncSession.getI  sJ     * $$d&7&7&;&;</+)/	
 	
 		
 	
   2;9;c               z   #    [        [        SU R                  R                  5      UUUUUUUS9I Sh  vN $  N7f)a  Return an instance based on the given primary key identifier,
or raise an exception if not found.

Raises :class:`_exc.NoResultFound` if the query selects no rows.

..versionadded: 2.0.22

.. seealso::

    :meth:`_orm.Session.get_one` - main documentation for get_one

r   r   N)r$   r   r   get_oner   s           rS   r   AsyncSession.get_onei  sJ     0 $$d&7&7&?&?@/+)/	
 	
 		
 	
r   c                  #    g 7frP   rd   r   s         rS   streamAsyncSession.stream  s
      r   c                  #    g 7frP   rd   r   s         rS   r   r     r   r   c                  #    U(       a*  [         R                  " U5      R                  [        5      nO[        n[	        U R
                  R                  U4UUUS.UD6I Sh  vN n[        U5      $  N7f)zRExecute a statement and return a streaming
:class:`_asyncio.AsyncResult` object.

r   N)r   r   r   _STREAM_OPTIONSr$   r   r   r   r   s          rS   r   r     s       $ 2 23D E K K! !0%%%
 /)
 
 
 6""
s   A A4"A2#A4c                  #    g 7frP   rd   r   s         rS   stream_scalarsAsyncSession.stream_scalars  s
      !$r   c                  #    g 7frP   rd   r   s         rS   r   r     s
      "%r   c               l   #    U R                   " U4UUUS.UD6I Sh  vN nUR                  5       $  N7f)a"  Execute a statement and return a stream of scalar results.

:return: an :class:`_asyncio.AsyncScalarResult` object

.. versionadded:: 1.4.24

.. seealso::

    :meth:`_orm.Session.scalars` - main documentation for scalars

    :meth:`_asyncio.AsyncSession.scalars` - non streaming version

r   N)r   r   r   s          rS   r   r     sI     . {{
/)	

 
 
 ~~
r   c                `   #    [        U R                  R                  U5      I Sh  vN   g N7f)a$  Mark an instance as deleted.

The database delete operation occurs upon ``flush()``.

As this operation may need to cascade along unloaded relationships,
it is awaitable to allow for those queries to take place.

.. seealso::

    :meth:`_orm.Session.delete` - main documentation for delete

N)r$   r   deleterR   r   s     rS   r   AsyncSession.delete  s#      T..55x@@@r   loadr   c               \   #    [        U R                  R                  XUS9I Sh  vN $  N7f)zCopy the state of a given instance into a corresponding instance
within this :class:`_asyncio.AsyncSession`.

.. seealso::

    :meth:`_orm.Session.merge` - main documentation for merge

r   N)r$   r   merge)rR   r   r   r   s       rS   r   AsyncSession.merge  s1      $##X'
 
 	
 
s   #,*,c                \   #    [        U R                  R                  US9I Sh  vN   g N7f)z|Flush all the object changes to the database.

.. seealso::

    :meth:`_orm.Session.flush` - main documentation for flush

)objectsN)r$   r   flush)rR   r   s     rS   r   AsyncSession.flush  s#      T..44gFFFs   ",*,c                d    U R                   R                  5       nUb  [        R                  XS9$ g)zReturn the current root transaction in progress, if any.

:return: an :class:`_asyncio.AsyncSessionTransaction` object, or
 ``None``.

.. versionadded:: 1.4.18

Nasync_session)r   get_transactionAsyncSessionTransaction_retrieve_proxy_for_targetrR   transs     rS   r   AsyncSession.get_transaction#  s?     !!113*EE F   rV   c                d    U R                   R                  5       nUb  [        R                  XS9$ g)zReturn the current nested transaction in progress, if any.

:return: an :class:`_asyncio.AsyncSessionTransaction` object, or
 ``None``.

.. versionadded:: 1.4.18

Nr   )r   get_nested_transactionr   r   r   s     rS   r   #AsyncSession.get_nested_transaction4  s?     !!88:*EE F   rV   c                @    U R                   R                  " SXUS.UD6$ )a  Return a "bind" to which the synchronous proxied :class:`_orm.Session`
is bound.

Unlike the :meth:`_orm.Session.get_bind` method, this method is
currently **not** used by this :class:`.AsyncSession` in any way
in order to resolve engines for requests.

.. note::

    This method proxies directly to the :meth:`_orm.Session.get_bind`
    method, however is currently **not** useful as an override target,
    in contrast to that of the :meth:`_orm.Session.get_bind` method.
    The example below illustrates how to implement custom
    :meth:`_orm.Session.get_bind` schemes that work with
    :class:`.AsyncSession` and :class:`.AsyncEngine`.

The pattern introduced at :ref:`session_custom_partitioning`
illustrates how to apply a custom bind-lookup scheme to a
:class:`_orm.Session` given a set of :class:`_engine.Engine` objects.
To apply a corresponding :meth:`_orm.Session.get_bind` implementation
for use with a :class:`.AsyncSession` and :class:`.AsyncEngine`
objects, continue to subclass :class:`_orm.Session` and apply it to
:class:`.AsyncSession` using
:paramref:`.AsyncSession.sync_session_class`. The inner method must
continue to return :class:`_engine.Engine` instances, which can be
acquired from a :class:`_asyncio.AsyncEngine` using the
:attr:`_asyncio.AsyncEngine.sync_engine` attribute::

    # using example from "Custom Vertical Partitioning"


    import random

    from sqlalchemy.ext.asyncio import AsyncSession
    from sqlalchemy.ext.asyncio import create_async_engine
    from sqlalchemy.ext.asyncio import async_sessionmaker
    from sqlalchemy.orm import Session

    # construct async engines w/ async drivers
    engines = {
        "leader": create_async_engine("sqlite+aiosqlite:///leader.db"),
        "other": create_async_engine("sqlite+aiosqlite:///other.db"),
        "follower1": create_async_engine("sqlite+aiosqlite:///follower1.db"),
        "follower2": create_async_engine("sqlite+aiosqlite:///follower2.db"),
    }


    class RoutingSession(Session):
        def get_bind(self, mapper=None, clause=None, **kw):
            # within get_bind(), return sync engines
            if mapper and issubclass(mapper.class_, MyOtherClass):
                return engines["other"].sync_engine
            elif self._flushing or isinstance(clause, (Update, Delete)):
                return engines["leader"].sync_engine
            else:
                return engines[
                    random.choice(["follower1", "follower2"])
                ].sync_engine


    # apply to AsyncSession using sync_session_class
    AsyncSessionMaker = async_sessionmaker(sync_session_class=RoutingSession)

The :meth:`_orm.Session.get_bind` method is called in a non-asyncio,
implicitly non-blocking context in the same manner as ORM event hooks
and functions that are invoked via :meth:`.AsyncSession.run_sync`, so
routines that wish to run SQL commands inside of
:meth:`_orm.Session.get_bind` can continue to do so using
blocking-style code, which will be translated to implicitly async calls
at the point of invoking IO on the database drivers.

)mapperclauser   rd   )r   get_bind)rR   r   r   r   r   s        rS   r   AsyncSession.get_bindF  s0    `   )) 
t
79
 	
rV   c                   #    [        U R                  R                  4UUS.UD6I Sh  vN n[        R                  R                  U5      $  N#7f)a  Return a :class:`_asyncio.AsyncConnection` object corresponding to
this :class:`.Session` object's transactional state.

This method may also be used to establish execution options for the
database connection used by the current transaction.

.. versionadded:: 1.4.24  Added \**kw arguments which are passed
   through to the underlying :meth:`_orm.Session.connection` method.

.. seealso::

    :meth:`_orm.Session.connection` - main documentation for
    "connection"

)r   r   N)r$   r   
connectionr   r'   r   )rR   r   r   r   sync_connections        rS   r  AsyncSession.connection  s]     , !/((!
)/!
 	!
 
 %%@@
 	

s   'AA$Ac                    [        U 5      $ )a  Return an :class:`_asyncio.AsyncSessionTransaction` object.

The underlying :class:`_orm.Session` will perform the
"begin" action when the :class:`_asyncio.AsyncSessionTransaction`
object is entered::

    async with async_session.begin():
        ...  # ORM transaction is begun

Note that database IO will not normally occur when the session-level
transaction is begun, as database transactions begin on an
on-demand basis.  However, the begin block is async to accommodate
for a :meth:`_orm.SessionEvents.after_transaction_create`
event hook that may perform IO.

For a general description of ORM begin, see
:meth:`_orm.Session.begin`.

r   rg   s    rS   beginAsyncSession.begin  s    * 't,,rV   c                    [        U SS9$ )a  Return an :class:`_asyncio.AsyncSessionTransaction` object
which will begin a "nested" transaction, e.g. SAVEPOINT.

Behavior is the same as that of :meth:`_asyncio.AsyncSession.begin`.

For a general description of ORM begin nested, see
:meth:`_orm.Session.begin_nested`.

.. seealso::

    :ref:`aiosqlite_serializable` - special workarounds required
    with the SQLite asyncio driver in order for SAVEPOINT to work
    correctly.

T)nestedr  rg   s    rS   begin_nestedAsyncSession.begin_nested  s    " 'tD99rV   c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)zRollback the current transaction in progress.

.. seealso::

    :meth:`_orm.Session.rollback` - main documentation for
    "rollback"
N)r$   r   rollbackrg   s    rS   r  AsyncSession.rollback  s!      T..77888   #-+-c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)zCommit the current transaction in progress.

.. seealso::

    :meth:`_orm.Session.commit` - main documentation for
    "commit"
N)r$   r   commitrg   s    rS   r  AsyncSession.commit  s!      T..55666r  c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)aE  Close out the transactional resources and ORM objects used by this
:class:`_asyncio.AsyncSession`.

.. seealso::

    :meth:`_orm.Session.close` - main documentation for
    "close"

    :ref:`session_closing` - detail on the semantics of
    :meth:`_asyncio.AsyncSession.close` and
    :meth:`_asyncio.AsyncSession.reset`.

N)r$   r   closerg   s    rS   r  AsyncSession.close  s!      T..44555r  c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)a  Close out the transactional resources and ORM objects used by this
:class:`_orm.Session`, resetting the session to its initial state.

.. versionadded:: 2.0.22

.. seealso::

    :meth:`_orm.Session.reset` - main documentation for
    "reset"

    :ref:`session_closing` - detail on the semantics of
    :meth:`_asyncio.AsyncSession.close` and
    :meth:`_asyncio.AsyncSession.reset`.

N)r$   r   resetrg   s    rS   r  AsyncSession.reset  s!       T..44555r  c                @   #    U R                  5       I Sh  vN   g N7f)zA synonym for :meth:`_asyncio.AsyncSession.close`.

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

.. versionadded:: 2.0.20

N)r  rg   s    rS   acloseAsyncSession.aclose  s      jjls   c                ^   #    [        U R                  R                  5      I Sh  vN   g N7f)zuClose this Session, using connection invalidation.

For a complete description, see :meth:`_orm.Session.invalidate`.
N)r$   r   
invalidaterg   s    rS   r  AsyncSession.invalidate&  s!     
 T..99:::r  z2.0zThe :meth:`.AsyncSession.close_all` method is deprecated and will be removed in a future release.  Please refer to :func:`_asyncio.close_all_sessions`.c                4   #    [        5       I Sh  vN   g N7f)z2Close all :class:`_asyncio.AsyncSession` sessions.Nr   r   s    rS   	close_allAsyncSession.close_all-  s      !"""s   c                   #    U $ 7frP   rd   rg   s    rS   
__aenter__AsyncSession.__aenter__8  s
     s   c                   #    [         R                  " U R                  5       5      n[         R                  " U5      I S h  vN   g  N7frP   )asynciocreate_taskr  shield)rR   type_value	tracebacktasks        rS   	__aexit__AsyncSession.__aexit__;  s-     ""4::<0nnT"""s   >A AAc                    [        U 5      $ rP   )_AsyncSessionContextManagerrg   s    rS   _maker_context_manager#AsyncSession._maker_context_manager?  s    *400rV   c                8    U R                   R                  U5      $ )a  Return True if the instance is associated with this session.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

The instance may be pending or persistent within the Session for a
result of True.


)r   rm   r   s     rS   rm   AsyncSession.__contains__G  s     }}))(33rV   c                6    U R                   R                  5       $ )zIterate over all pending or persistent instances within this
Session.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.


)r   rn   rg   s    rS   rn   AsyncSession.__iter__W  s     }}%%''rV   c                4    U R                   R                  XS9$ )a  Place an object into this :class:`_orm.Session`.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

Objects that are in the :term:`transient` state when passed to the
:meth:`_orm.Session.add` method will move to the
:term:`pending` state, until the next flush, at which point they
will move to the :term:`persistent` state.

Objects that are in the :term:`detached` state when passed to the
:meth:`_orm.Session.add` method will move to the :term:`persistent`
state directly.

If the transaction used by the :class:`_orm.Session` is rolled back,
objects which were transient when they were passed to
:meth:`_orm.Session.add` will be moved back to the
:term:`transient` state, and will no longer be present within this
:class:`_orm.Session`.

.. seealso::

    :meth:`_orm.Session.add_all`

    :ref:`session_adding` - at :ref:`session_basics`


)_warn)r   ro   )rR   r   r:  s      rS   ro   AsyncSession.adde  s    @ }}   77rV   c                8    U R                   R                  U5      $ )a  Add the given collection of instances to this :class:`_orm.Session`.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

See the documentation for :meth:`_orm.Session.add` for a general
behavioral description.

.. seealso::

    :meth:`_orm.Session.add`

    :ref:`session_adding` - at :ref:`session_basics`


)r   rp   )rR   	instancess     rS   rp   AsyncSession.add_all  s    ( }}$$Y//rV   c                4    U R                   R                  XS9$ )a  Expire the attributes on an instance.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

Marks the attributes of an instance as out of date. When an expired
attribute is next accessed, a query will be issued to the
:class:`.Session` object's current transactional context in order to
load all expired attributes for the given instance.   Note that
a highly isolated transaction will return the same values as were
previously read in that same transaction, regardless of changes
in database state outside of that transaction.

To expire all objects in the :class:`.Session` simultaneously,
use :meth:`Session.expire_all`.

The :class:`.Session` object's default behavior is to
expire all state whenever the :meth:`Session.rollback`
or :meth:`Session.commit` methods are called, so that new
state can be loaded for the new transaction.   For this reason,
calling :meth:`Session.expire` only makes sense for the specific
case that a non-ORM SQL statement was emitted in the current
transaction.

:param instance: The instance to be refreshed.
:param attribute_names: optional list of string attribute names
  indicating a subset of attributes to be expired.

.. seealso::

    :ref:`session_expire` - introductory material

    :meth:`.Session.expire`

    :meth:`.Session.refresh`

    :meth:`_orm.Query.populate_existing`


)r   )r   rq   )rR   r   r   s      rS   rq   AsyncSession.expire  s    \ }}##H#NNrV   c                6    U R                   R                  5       $ )a  Expires all persistent instances within this Session.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

When any attributes on a persistent instance is next accessed,
a query will be issued using the
:class:`.Session` object's current transactional context in order to
load all expired attributes for the given instance.   Note that
a highly isolated transaction will return the same values as were
previously read in that same transaction, regardless of changes
in database state outside of that transaction.

To expire individual objects and individual attributes
on those objects, use :meth:`Session.expire`.

The :class:`.Session` object's default behavior is to
expire all state whenever the :meth:`Session.rollback`
or :meth:`Session.commit` methods are called, so that new
state can be loaded for the new transaction.   For this reason,
calling :meth:`Session.expire_all` is not usually needed,
assuming the transaction is isolated.

.. seealso::

    :ref:`session_expire` - introductory material

    :meth:`.Session.expire`

    :meth:`.Session.refresh`

    :meth:`_orm.Query.populate_existing`


)r   rr   rg   s    rS   rr   AsyncSession.expire_all  s    N }}''))rV   c                8    U R                   R                  U5      $ )a4  Remove the `instance` from this ``Session``.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

This will free all internal references to the instance.  Cascading
will be applied according to the *expunge* cascade rule.


)r   rs   r   s     rS   rs   AsyncSession.expunge  s     }}$$X..rV   c                6    U R                   R                  5       $ )a  Remove all object instances from this ``Session``.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

This is equivalent to calling ``expunge(obj)`` on all objects in this
``Session``.


)r   rt   rg   s    rS   rt   AsyncSession.expunge_all  s     }}((**rV   c                4    U R                   R                  XS9$ )a	  Return ``True`` if the given instance has locally
modified attributes.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

This method retrieves the history for each instrumented
attribute on the instance and performs a comparison of the current
value to its previously flushed or committed value, if any.

It is in effect a more expensive and accurate
version of checking for the given instance in the
:attr:`.Session.dirty` collection; a full test for
each attribute's net "dirty" status is performed.

E.g.::

    return session.is_modified(someobject)

A few caveats to this method apply:

* Instances present in the :attr:`.Session.dirty` collection may
  report ``False`` when tested with this method.  This is because
  the object may have received change events via attribute mutation,
  thus placing it in :attr:`.Session.dirty`, but ultimately the state
  is the same as that loaded from the database, resulting in no net
  change here.
* Scalar attributes may not have recorded the previously set
  value when a new value was applied, if the attribute was not loaded,
  or was expired, at the time the new value was received - in these
  cases, the attribute is assumed to have a change, even if there is
  ultimately no net change against its database value. SQLAlchemy in
  most cases does not need the "old" value when a set event occurs, so
  it skips the expense of a SQL call if the old value isn't present,
  based on the assumption that an UPDATE of the scalar value is
  usually needed, and in those few cases where it isn't, is less
  expensive on average than issuing a defensive SELECT.

  The "old" value is fetched unconditionally upon set only if the
  attribute container has the ``active_history`` flag set to ``True``.
  This flag is set typically for primary key attributes and scalar
  object references that are not a simple many-to-one.  To set this
  flag for any arbitrary mapped column, use the ``active_history``
  argument with :func:`.column_property`.

:param instance: mapped instance to be tested for pending changes.
:param include_collections: Indicates if multivalued collections
 should be included in the operation.  Setting this to ``False`` is a
 way to detect only local-column based properties (i.e. scalar columns
 or many-to-one foreign keys) that would result in an UPDATE for this
 instance upon flush.


)include_collections)r   ru   )rR   r   rH  s      rS   ru   AsyncSession.is_modified  s$    x }}(( ) 
 	
rV   c                6    U R                   R                  5       $ )a  Return True if this :class:`_orm.Session` has begun a transaction.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

.. versionadded:: 1.4

.. seealso::

    :attr:`_orm.Session.is_active`



)r   rv   rg   s    rS   rv   AsyncSession.in_transactionV  s    $ }}++--rV   c                6    U R                   R                  5       $ )zReturn True if this :class:`_orm.Session` has begun a nested
transaction, e.g. SAVEPOINT.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

.. versionadded:: 1.4


)r   rw   rg   s    rS   rw   "AsyncSession.in_nested_transactionj  s     }}2244rV   c                .    U R                   R                  $ )ak  The set of all persistent instances considered dirty.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class
    on behalf of the :class:`_asyncio.AsyncSession` class.

E.g.::

    some_mapped_object in session.dirty

Instances are considered dirty when they were modified but not
deleted.

Note that this 'dirty' calculation is 'optimistic'; most
attribute-setting or collection modification operations will
mark an instance as 'dirty' and place it in this set, even if
there is no net change to the attribute's value.  At flush
time, the value of each attribute is compared to its
previously saved value, and if there's no net change, no SQL
operation will occur (this is a more expensive operation so
it's only done at flush time).

To check if an instance has actionable net changes to its
attributes, use the :meth:`.Session.is_modified` method.


)r   rx   rg   s    rS   rx   AsyncSession.dirtyz  s    > }}"""rV   c                .    U R                   R                  $ )zThe set of all instances marked as 'deleted' within this ``Session``

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class
    on behalf of the :class:`_asyncio.AsyncSession` class.

)r   ry   rg   s    rS   ry   AsyncSession.deleted  s     }}$$$rV   c                .    U R                   R                  $ )zThe set of all instances marked as 'new' within this ``Session``.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class
    on behalf of the :class:`_asyncio.AsyncSession` class.

)r   rz   rg   s    rS   rz   AsyncSession.new  s     }}   rV   c                .    U R                   R                  $ )zrProxy for the :attr:`_orm.Session.identity_map` attribute
on behalf of the :class:`_asyncio.AsyncSession` class.

r   r{   rg   s    rS   r{   AsyncSession.identity_map  s     }})))rV   c                $    XR                   l        g rP   rU  rR   attrs     rS   r{   rV    s    %)"rV   c                .    U R                   R                  $ )a5  True if this :class:`.Session` not in "partial rollback" state.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class
    on behalf of the :class:`_asyncio.AsyncSession` class.

.. versionchanged:: 1.4 The :class:`_orm.Session` no longer begins
   a new transaction immediately, so this attribute will be False
   when the :class:`_orm.Session` is first instantiated.

"partial rollback" state typically indicates that the flush process
of the :class:`_orm.Session` has failed, and that the
:meth:`_orm.Session.rollback` method must be emitted in order to
fully roll back the transaction.

If this :class:`_orm.Session` is not in a transaction at all, the
:class:`_orm.Session` will autobegin when it is first used, so in this
case :attr:`_orm.Session.is_active` will return True.

Otherwise, if this :class:`_orm.Session` is within a transaction,
and that transaction has not been rolled back internally, the
:attr:`_orm.Session.is_active` will also return True.

.. seealso::

    :ref:`faq_session_rollback`

    :meth:`_orm.Session.in_transaction`


)r   r|   rg   s    rS   r|   AsyncSession.is_active  s    F }}&&&rV   c                .    U R                   R                  $ )zoProxy for the :attr:`_orm.Session.autoflush` attribute
on behalf of the :class:`_asyncio.AsyncSession` class.

r   r}   rg   s    rS   r}   AsyncSession.autoflush  s     }}&&&rV   c                $    XR                   l        g rP   r]  rX  s     rS   r}   r^    s    "&rV   c                .    U R                   R                  $ )a  Return a context manager that disables autoflush.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class
    on behalf of the :class:`_asyncio.AsyncSession` class.

e.g.::

    with session.no_autoflush:

        some_object = SomeClass()
        session.add(some_object)
        # won't autoflush
        some_object.related_thing = session.query(SomeRelated).first()

Operations that proceed within the ``with:`` block
will not be subject to flushes occurring upon query
access.  This is useful when initializing a series
of objects which involve existing database queries,
where the uncompleted object should not yet be flushed.


)r   r~   rg   s    rS   r~   AsyncSession.no_autoflush  s    6 }})))rV   c                .    U R                   R                  $ )a  A user-modifiable dictionary.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class
    on behalf of the :class:`_asyncio.AsyncSession` class.

The initial value of this dictionary can be populated using the
``info`` argument to the :class:`.Session` constructor or
:class:`.sessionmaker` constructor or factory methods.  The dictionary
here is always local to this :class:`.Session` and can be modified
independently of all other :class:`.Session` objects.


)r   r   rg   s    rS   r   AsyncSession.info  s    $ }}!!!rV   c                .    [         R                  " U5      $ )zReturn the :class:`.Session` to which an object belongs.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

This is an alias of :func:`.object_session`.


)r!   r    )r   r   s     rS   r    AsyncSession.object_session%  s     %%h//rV   )r   rowr   c               2    [         R                  " UUUUUS9$ )zReturn an identity key.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_asyncio.AsyncSession` class.

This is an alias of :func:`.util.identity_key`.


)class_r   r   rf  r   )r!   rl   )r   rh  r   r   rf  r   s         rS   rl   AsyncSession.identity_key5  s&    , ##)
 	
rV   )r   r   r   r   r   rP   )r   Optional[_AsyncSessionBind]r   z2Optional[Dict[_SessionBindKey, _AsyncSessionBind]]r   zOptional[Type[Session]]r   r   )r]   r   )NN)r   objectr   Optional[Iterable[str]]r   rA   r]   None)r   z&Callable[Concatenate[Session, _P], _T]r   z_P.argsr   z	_P.kwargsr]   rD   )r   TypedReturnsRows[_T]r   Optional[_CoreAnyExecuteParams]r   r5   r   Optional[_BindArguments]r   Optional[Any]r   rq  r]   z
Result[_T])r   r?   r   ro  r   r5   r   rp  r   rq  r   rq  r]   zCursorResult[Any])r   r>   r   ro  r   r5   r   rp  r   rq  r   rq  r]   Result[Any])r   r>   r   ro  r   r5   r   rp  r   r   r]   rr  )r   TypedReturnsRows[Tuple[_T]]r   ro  r   r5   r   rp  r   r   r]   zOptional[_T])r   r>   r   ro  r   r5   r   rp  r   r   r]   r   )r   rs  r   ro  r   r5   r   rp  r   r   r]   zScalarResult[_T])r   r>   r   ro  r   r5   r   rp  r   r   r]   zScalarResult[Any])r   _EntityBindKey[_O]r   r:   r   Optional[Sequence[ORMOption]]r   boolr   rA   r   rq  r   r5   r]   zUnion[_O, None])r   rt  r   r:   r   ru  r   rv  r   rA   r   rq  r   r5   r]   r4   )r   rn  r   ro  r   r5   r   rp  r   r   r]   zAsyncResult[_T])r   r>   r   ro  r   r5   r   rp  r   r   r]   zAsyncResult[Any])r   rs  r   ro  r   r5   r   rp  r   r   r]   zAsyncScalarResult[_T])r   r>   r   ro  r   r5   r   rp  r   r   r]   zAsyncScalarResult[Any])r   rk  r]   rm  )r   r4   r   rv  r   ru  r]   r4   )r   zOptional[Sequence[Any]]r]   rm  )r]   z!Optional[AsyncSessionTransaction])NNN)
r   zOptional[_EntityBindKey[_O]]r   zOptional[ClauseElement]r   zOptional[_SessionBind]r   r   r]   zUnion[Engine, Connection])r   rp  r   z%Optional[CoreExecuteOptionsParameter]r   r   r]   r'   )r]   r   r]   rm  )rR   _ASr]   rx  r+  r   r,  r   r-  r   r]   rm  )rR   rx  r]    _AsyncSessionContextManager[_AS])r   rk  r]   rv  )r]   zIterator[object])T)r   rk  r:  rv  r]   rm  )r=  zIterable[object]r]   rm  )r   rk  r   rl  r]   rm  )r   rk  rH  rv  r]   rv  r]   rv  )r]   r   )r]   r6   )rY  r6   r]   rm  )rY  rv  r]   rm  )r   rk  r]   zOptional[Session])rh  zOptional[Type[Any]]r   zUnion[Any, Tuple[Any, ...]]r   rq  rf  z%Optional[Union[Row[Any], RowMapping]]r   rq  r]   z_IdentityKeyType[Any])Dr^   r_   r`   ra   rj   _is_asyncio__annotations__rT   r!   r   classmethodr   r   r   r   r   
EMPTY_DICTr   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  
deprecatedr"  r%  r/  r3  rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rk   rx   ry   rz   r{   setterr|   r}   r~   r   r    rl   rc   rd   rV   rS   r   r      s
   <" K!! -1,
 EI6:,
),
 B	,

 4,
 ,
\ )0/  	 
 
 48.2	

 1
 ,	

 

6>
2>
 >
 	>

 
>
@  37	
 9=37/3$(	'	 0	
 6	 1	  -	 "	 
	 	  37	 
 9=37/3$(	 	  0	 
 6	  1	   -	  "	  
	  	   37	
 9=37/3$(		 0	
 6	 1	  -	 "	 
	 	 37!?
 9=37!?!? 0!?
 6!? 1!? !? 
!?F  37
 9=37. 0
 6 1  
   37
 9=37 0
 6 1  
  37

 9=37

 0

 6
 1
 
 

B  37
 9=37. 0
 6 1  
   37 
 9=37   0 
 6  1    
    37! 
 9=37! !  0! 
 6!  1!  !  
! P 26"'.2(,8<
"
 #

 /
  
 ,
 &
 6
 

J 26"'.2(,8<!
"!
 #!

 /!
  !
 ,!
 &!
 6!
 
!
F  37
 9=37' 0
 6 1  
   37
 9=37 0
 6 1  
  37#
 9=37## 0#
 6# 1# # 
#>  37$
 9=37$.$ 0$
 6$ 1$ $ 
$ $  37%
 9=37%% 0%
 6% 1% % 
 % % 37 
 9=37   0 
 6  1    
  @A& 15

 	

 /
 

&G"( 04*.'+	R
,R
 (R
 %	R

 R
 
#R
l 48CG
0
 A
 	

 

@-.:&976 6$
; 	__	/# ##14 ( 8D0. LP.O.O1H.O	.O`'*R/ +" =A>
>
59>
	>
@.(5  # #@ 
% 
% 
! 
! * * * * "' "'H ' ' ' ' * *8 " "& 0 0  '+-1

 #'59(,
#
 +

  
 3
 &
 

 
rV   r   rx  c                      \ rS rSr% SrS\S'   \ SSSSS.           SS jjj5       r\ SSSSS.           SS jjj5       r S\S
S
S	S.           SS jjjrSS jr	SS jr
SS jrSS jrSrg	)async_sessionmakeriY  a  A configurable :class:`.AsyncSession` factory.

The :class:`.async_sessionmaker` factory works in the same way as the
:class:`.sessionmaker` factory, to generate new :class:`.AsyncSession`
objects when called, creating them given
the configurational arguments established here.

e.g.::

    from sqlalchemy.ext.asyncio import create_async_engine
    from sqlalchemy.ext.asyncio import AsyncSession
    from sqlalchemy.ext.asyncio import async_sessionmaker


    async def run_some_sql(
        async_session: async_sessionmaker[AsyncSession],
    ) -> None:
        async with async_session() as session:
            session.add(SomeObject(data="object"))
            session.add(SomeOtherObject(name="other object"))
            await session.commit()


    async def main() -> None:
        # an AsyncEngine, which the AsyncSession will use for connection
        # resources
        engine = create_async_engine(
            "postgresql+asyncpg://scott:tiger@localhost/"
        )

        # create a reusable factory for new AsyncSession instances
        async_session = async_sessionmaker(engine)

        await run_some_sql(async_session)

        await engine.dispose()

The :class:`.async_sessionmaker` is useful so that different parts
of a program can create new :class:`.AsyncSession` objects with a
fixed configuration established up front.  Note that :class:`.AsyncSession`
objects may also be instantiated directly when not using
:class:`.async_sessionmaker`.

.. versionadded:: 2.0  :class:`.async_sessionmaker` provides a
   :class:`.sessionmaker` class that's dedicated to the
   :class:`.AsyncSession` object, including pep-484 typing support.

.. seealso::

    :ref:`asyncio_orm` - shows example use

    :class:`.sessionmaker`  - general overview of the
     :class:`.sessionmaker` architecture


    :ref:`session_getting` - introductory text on creating
    sessions using :class:`.sessionmaker`.

	Type[_AS]rh  .)r}   expire_on_commitr   c                   g rP   rd   rR   r   rh  r}   r  r   r   s          rS   rT   async_sessionmaker.__init__  s     rV   c                   g rP   rd   )rR   r   r}   r  r   r   s         rS   rT   r    s     rV   NT)rh  r}   r  r   c               B    XS'   X6S'   XFS'   Ub  XVS'   X`l         X l        g)zConstruct a new :class:`.async_sessionmaker`.

All arguments here except for ``class_`` correspond to arguments
accepted by :class:`.Session` directly. See the
:meth:`.AsyncSession.__init__` docstring for more details on
parameters.


r   r}   r  Nr   )r   rh  r  s          rS   rT   r    s2    & 6
#;!1vJrV   c                0    U " 5       nUR                  5       $ )aL  Produce a context manager that both provides a new
:class:`_orm.AsyncSession` as well as a transaction that commits.


e.g.::

    async def main():
        Session = async_sessionmaker(some_engine)

        async with Session.begin() as session:
            session.add(some_object)

        # commits transaction, closes session

)r3  )rR   sessions     rS   r  async_sessionmaker.begin  s    " &--//rV   c                    U R                   R                  5        HL  u  p#US:X  a0  SU;   a*  UR                  5       nUR                  US   5        XAS'   M;  UR	                  X#5        MN     U R
                  " S0 UD6$ )at  Produce a new :class:`.AsyncSession` object using the configuration
established in this :class:`.async_sessionmaker`.

In Python, the ``__call__`` method is invoked on an object when
it is "called" in the same way as a function::

    AsyncSession = async_sessionmaker(async_engine, expire_on_commit=False)
    session = AsyncSession()  # invokes sessionmaker.__call__()

r   rd   )r   r   copyupdate
setdefaultrh  )rR   local_kwkvds        rS   __call__async_sessionmaker.__call__  sn     GGMMODAF{v1FFH&)*#$ ##A) $ {{&X&&rV   c                :    U R                   R                  U5        g)z(Re)configure the arguments for this async_sessionmaker.

e.g.::

    AsyncSession = async_sessionmaker(some_engine)

    AsyncSession.configure(bind=create_async_engine("sqlite+aiosqlite://"))
N)r   r  )rR   new_kws     rS   	configureasync_sessionmaker.configure  s     	vrV   c           	         U R                   R                  < SU R                  R                  < SSR                  S U R                  R                  5        5       5      < S3$ )Nz(class_=z, c              3  8   #    U  H  u  pU< S U< 3v   M     g7f)=Nrd   ).0r  r  s      rS   	<genexpr>.async_sessionmaker.__repr__.<locals>.<genexpr>  s     C?41A&?s   ))	__class__r^   rh  joinr   r   rg   s    rS   __repr__async_sessionmaker.__repr__  sB    NN##KK  IIC477==?CC
 	
rV   )rh  r   ).)r   rj  rh  r  r}   rv  r  rv  r   Optional[_InfoType]r   r   )rR   z"'async_sessionmaker[AsyncSession]'r   rj  r}   rv  r  rv  r   r  r   r   rP   )r]   rz  )r  r   r]   rx  )r  r   r]   rm  )r]   r\   )r^   r_   r`   ra   rj   r}  r   rT   r   r  r  r  r  rc   rd   rV   rS   r  r  Y  s=   :x  -0	
 !$$'	)	 		
 	 	 "	 	 	  -0 !$$'0) 	
  "   -1 )!%$() 	
   " 60('(

rV   r  c                  L    \ rS rSr% SrS\S'   S\S'   SS jrSS jrSS	 jrSr	g
)r2  i  )r   r   rx  r   r   r   c                    Xl         g rP   r   )rR   r   s     rS   rT   $_AsyncSessionContextManager.__init__  s    *rV   c                   #    U R                   R                  5       U l        U R                  R                  5       I S h  vN   U R                   $  N7frP   )r   r  r   r%  rg   s    rS   r%  &_AsyncSessionContextManager.__aenter__  sB     ''--/
jj##%%%!!! 	&s   =AA Ac                   ^ ^^^#    SU UUU4S jjn[         R                  " U" 5       5      n[         R                  " U5      I S h  vN   g  N7f)Nc                    >#    T R                   R                  TTT5      I S h  vN   T R                  R                  TTT5      I S h  vN   g  N* N7frP   )r   r/  r   )rR   r-  r+  r,  s   rS   go1_AsyncSessionContextManager.__aexit__.<locals>.go  sI     **&&ueY???$$..ueYGGG @Gs!   !AA$A	A
AArw  )r(  r)  r*  )rR   r+  r,  r-  r  r.  s   ````  rS   r/  %_AsyncSessionContextManager.__aexit__  s8     	H 	H ""24(nnT"""s   A AAAN)r   rx  )r]   rx  ry  )
r^   r_   r`   ra   rb   r}  rT   r%  r/  rc   rd   rV   rS   r2  r2    s"    *I""+"
#rV   r2  c                      \ rS rSr% SrSrS\S'   S\S'   SSS jjr\SS	 j5       r	SS
 jr
SS jrSS jr\        SS j5       r S   SS jjrSS jrSrg)r   i  a  A wrapper for the ORM :class:`_orm.SessionTransaction` object.

This object is provided so that a transaction-holding object
for the :meth:`_asyncio.AsyncSession.begin` may be returned.

The object supports both explicit calls to
:meth:`_asyncio.AsyncSessionTransaction.commit` and
:meth:`_asyncio.AsyncSessionTransaction.rollback`, as well as use as an
async context manager.


.. versionadded:: 1.4

)r  sync_transactionr  r   r  zOptional[SessionTransaction]r  c                *    Xl         X l        S U l        g rP   )r  r  r  )rR   r  r  s      rS   rT    AsyncSessionTransaction.__init__5  s     $rV   c                h    U R                  5       S L=(       a    U R                  5       R                  $ rP   )_sync_transactionr|   rg   s    rS   r|   !AsyncSessionTransaction.is_active:  s1     ""$D0 3&&(22	
rV   c                \    U R                   (       d  U R                  5         U R                   $ rP   )r  _raise_for_not_startedrg   s    rS   r  )AsyncSessionTransaction._sync_transactionA  s#    $$'')$$$rV   c                f   #    [        U R                  5       R                  5      I Sh  vN   g N7f)z2Roll back this :class:`_asyncio.AsyncTransaction`.N)r$   r  r  rg   s    rS   r   AsyncSessionTransaction.rollbackF  s"     T335>>???   '1/1c                f   #    [        U R                  5       R                  5      I Sh  vN   g N7f)z/Commit this :class:`_asyncio.AsyncTransaction`.N)r$   r  r  rg   s    rS   r  AsyncSessionTransaction.commitJ  s$      T335<<===r  c                    UnUR                   nU R                  U 5      nX&l        UR                  U5      Ul        XVl         U$ rP   )r  __new__r  r   r  )r   targetr   additional_kwr  r  objs          rS   _regenerate_proxy_for_target4AsyncSessionTransaction._regenerate_proxy_for_targetO  sD     "kk##"223CD

rV   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rP   )	r   r$   r  r  r   r  r  r  	__enter__)rR   is_ctxmanagers     rS   startAsyncSessionTransaction.start^  sw      !% 4 4 ;; ))66\\..44 !
 !!++-s   A)B+B,1Bc                j   #    [        U R                  5       R                  XU5      I S h  vN   g  N7frP   )r$   r  __exit__)rR   r+  r,  r-  s       rS   r/  !AsyncSessionTransaction.__aexit__l  s-     ""$--uY
 	
 	
s   )313)r  r  r  N)F)r  r   r  rv  r{  )r]   r"   rw  )r  r"   r   r   r  r   r]   r   )r  rv  r]   r   ry  )r^   r_   r`   ra   rj   rb   r}  rT   rk   r|   r  r  r  r~  r  r  r/  rc   rd   rV   rS   r   r     s     :I22%
 
 
%
@>
 " $ 	
 
!  %*!	 
rV   r   c                6    [        U 5      nUb  [        U5      $ g)aw  Return the :class:`_asyncio.AsyncSession` to which the given instance
belongs.

This function makes use of the sync-API function
:class:`_orm.object_session` to retrieve the :class:`_orm.Session` which
refers to the given instance, and from there links it to the original
:class:`_asyncio.AsyncSession`.

If the :class:`_asyncio.AsyncSession` has been garbage collected, the
return value is ``None``.

This functionality is also available from the
:attr:`_orm.InstanceState.async_session` accessor.

:param instance: an ORM mapped instance
:return: an :class:`_asyncio.AsyncSession` object, or ``None``.

.. versionadded:: 1.4.18

N)r    r   )r   r  s     rS   async_object_sessionr  r  s"    , X&GW%%rV   c                *    [         R                  U SS9$ )zReturn the :class:`_asyncio.AsyncSession` which is proxying the given
:class:`_orm.Session` object, if any.

:param session: a :class:`_orm.Session` instance.
:return: a :class:`_asyncio.AsyncSession` instance, or ``None``.

.. versionadded:: 1.4.18

F)
regenerate)r   r   )r  s    rS   r   r     s     227u2MMrV   c                 >   #    [        [        5      I Sh  vN   g N7f)zClose all :class:`_asyncio.AsyncSession` sessions.

.. versionadded:: 2.0.23

.. seealso::

    :func:`.session.close_all_sessions`

N)r$   _sync_close_all_sessionsrd   rV   rS   r   r     s      1
222s   )r   rk  r]   Optional[AsyncSession])r  r!   r]   r  rw  )c
__future__r   r(  typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r    r   baser   r   r   r   r   r   r   ormr   r  r    r!   r"   r#   _instance_stateutil.concurrencyr$   util.typingr%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   engine.interfacesr0   r1   eventr2   orm._typingr3   r4   r5   orm.identityr6   orm.interfacesr7   orm.sessionr8   r9   r:   r;   r<   sql._typingr=   sql.baser>   sql.dmlr?   sql.elementsr@   sql.selectablerA   rB   _AsyncSessionBindrC   rD   r   r   r   rI   create_proxy_methodsr   rx  r  r2  r   r  r   _async_providerrd   rV   rS   <module>r     s   #                     ! " '  %  A !  % + . & $ '#$&  $&:@#/!9++--2+.(&%-42:; t_T %%'7&>? $$&6%=>Z2 Z2z $"N3	%:B
?7+ B
;:B
N, e>*j
 j
Z#'#, #.R
&'./R
j:
N
3 #0 rV   