gk ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZe rddlmZddl m!Z!ddl m"Z"ddlm#Z#ddlm$Z$dd lm%Z%dd!lm&Z&dd"lm'Z'dd#lm(Z(dd$lm)Z)dd%l*m+Z+dd&l*m,Z,dd'l-m.Z.dd(l/m0Z0dd)l/m1Z1dd*l/m2Z2dd+l3m4Z4dd,lm5Z5dd-lm6Z6dd.lm7Z7dd/lm8Z8dd0l9m:Z:dd1l;mZ>dd3l?m@Z@dd4l?mAZAed5e6ZBeed7d8gd9gd:gd;dd?eeZCy@)A) annotations)Any)Callable)Generic)Iterable)Iterator)Optional)overload)Sequence)Tuple)Type) TYPE_CHECKING)TypeVar)Union)_AS)async_sessionmaker) AsyncSession)exc)util)Session)create_proxy_methods)ScopedRegistry)warn)warn_deprecated)AsyncConnection) AsyncResult)AsyncScalarResult)AsyncSessionTransaction) Connection) CursorResult)Engine)Result)Row) RowMapping)_CoreAnyExecuteParams)CoreExecuteOptionsParameter) ScalarResult)_IdentityKeyType)_O)OrmExecuteOptionsParameter) ORMOption)_BindArguments)_EntityBindKey)_PKIdentityArgument) _SessionBind) Executable) UpdateBase) ClauseElement)ForUpdateParameter)TypedReturnsRows_T)boundz:class:`_asyncio.AsyncSession`z.:class:`_asyncio.scoping.async_scoped_session`) close_allobject_session identity_key) __contains____iter__acloseaddadd_allbegin begin_nestedcloseresetcommit connectiondeleteexecuteexpire expire_allexpunge expunge_allflushget_bind is_modified invalidatemergerefreshrollbackscalarscalarsgetget_onestreamstream_scalars) binddirtydeletednew identity_map is_active autoflush no_autoflushinforV) classmethodsmethods attributesuse_intermediate_variableceZdZUdZdZded< ded< dKdZedLdZdMd Z dNd Z dOd Z dPd Z dQd Z dOdZdRdSdZdTdZdUdZdUdZdOdZdOdZdOdZ dV dWdZdXdZe dYej4dddd dZdZe dYej4dddd d[dZe dYej4dddd d\dZ dYej4dd d]dZ dY d^dZdOd ZdXd!ZdOd"ZdYd_d#Z d` dad$Z! dR dbd%Z"dOd&Z#ddd' dcd(Z$ dV ddd)Z%dOd*Z&e dYej4dd ded+Z'e dYej4dd dfd,Z' dYej4dd dfd-Z'e dYej4dd dgd.Z(e dYej4dd dhd/Z( dYej4dd dhd0Z(dd1ddej4d2 did3Z)dd1ddej4d2 djd4Z*e dYej4dd dkd5Z+e dYej4dd dld6Z+ dYej4dd dld7Z+e dYej4dd dmd8Z,e dYej4dd dnd9Z, dYej4dd dnd:Z,edod;Z-e-j\dpd<Z-edod=Z/edod>Z0edod?Z1edod@Z2e2j\dpdAZ2edodBZ3edodCZ4e4j\dpdDZ4edodEZ5edodFZ6e7dOdGZ8e7dqdHZ9e7 dVddddI drdJZ:y)sasync_scoped_sessionzProvides scoped management of :class:`.AsyncSession` objects. See the section :ref:`asyncio_scoped_session` for usage details. .. versionadded:: 1.4.19 Tasync_sessionmaker[_AS]session_factoryzScopedRegistry[_AS]registryc4||_t|||_y)aConstruct a new :class:`_asyncio.async_scoped_session`. :param session_factory: a factory to create new :class:`_asyncio.AsyncSession` instances. This is usually, but not necessarily, an instance of :class:`_asyncio.async_sessionmaker`. :param scopefunc: function which defines the current scope. A function such as ``asyncio.current_task`` may be useful here. N)rjrrk)selfrj scopefuncs O/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/ext/asyncio/scoping.py__init__zasync_scoped_session.__init__s" /& B c"|jSN)rkrms ro_proxiedzasync_scoped_session._proxieds}}rqc ,|r]|jjrtjd|jdi|}|jj |n|j}|j s|jr tdd|S)aReturn the current :class:`.AsyncSession`, creating it using the :attr:`.scoped_session.session_factory` if not present. :param \**kw: Keyword arguments will be passed to the :attr:`.scoped_session.session_factory` callable, if an existing :class:`.AsyncSession` is not present. If the :class:`.AsyncSession` is present and keyword arguments have been passed, :exc:`~sqlalchemy.exc.InvalidRequestError` is raised. zEScoped session is already present; no new arguments may be specified.zUsing `scoped_session` with asyncio is deprecated and will raise an error in a future version. Please use `async_scoped_session` instead.z1.4.23) rkhassa_excInvalidRequestErrorrjset_support_async _is_asyncior)rmkwsesss ro__call__zasync_scoped_session.__call__s }}  "009 ,t++1b1 !!$'==?D""t'7'7 =    rqc |jjr td|jjdi|y)zreconfigure the :class:`.sessionmaker` used by this :class:`.scoped_session`. See :meth:`.sessionmaker.configure`. ztAt least one scoped session is already present. configure() can not affect sessions that have already been created.Nrw)rkrxrrj configure)rmkwargss rorzasync_scoped_session.configures< ==    (  '&&00rqcK|jjr&|jjd{|jjy7w)zDispose of the current :class:`.AsyncSession`, if present. Different from scoped_session's remove method, this method would use await to wait for the close method of AsyncSession. N)rkrxrCclearrts roremovezasync_scoped_session.removesE ==   --/'') ) )  *srts ror>zasync_scoped_session.aclose s!"]]))++++ '%'c<|jj||S)aPlace an object into this :class:`_orm.Session`. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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)rur?)rmrrs ror?zasync_scoped_session.addsL}}   77rqc8|jj|S)aAdd the given collection of instances to this :class:`_orm.Session`. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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` )rur@)rm instancess ror@zasync_scoped_session.add_allFs4}}$$Y//rqc6|jjS)aReturn an :class:`_asyncio.AsyncSessionTransaction` object. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. 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`. )rurArts rorAzasync_scoped_session.beginbs6}}""$$rqc6|jjS)aReturn an :class:`_asyncio.AsyncSessionTransaction` object which will begin a "nested" transaction, e.g. SAVEPOINT. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. 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. )rurBrts rorBz!async_scoped_session.begin_nesteds.}}))++rqcRK|jjd{S7w)a?Close out the transactional resources and ORM objects used by this :class:`_asyncio.AsyncSession`. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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)rurCrts rorCzasync_scoped_session.closes!*]]((****rcRK|jjd{S7w)aClose out the transactional resources and ORM objects used by this :class:`_orm.Session`, resetting the session to its initial state. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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)rurDrts rorDzasync_scoped_session.resets!.]]((****rcRK|jjd{S7w)a[Commit the current transaction in progress. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. seealso:: :meth:`_orm.Session.commit` - main documentation for "commit" N)rurErts rorEzasync_scoped_session.commits!]]))++++rNc\K|jjd||d|d{S7w)aReturn a :class:`_asyncio.AsyncConnection` object corresponding to this :class:`.Session` object's transactional state. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. 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" )bind_argumentsexecution_optionsNrw)rurF)rmrrr~s rorFzasync_scoped_session.connections@8.T]]-- )/     s #,*,cTK|jj|d{S7w)aMark an instance as deleted. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. 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)rurGrs rorGzasync_scoped_session.deletes#(]]))(3333s (&()rr_parent_execute_state _add_eventc Kywrsrwrm statementparamsrrrrs rorHzasync_scoped_session.executes c Kywrsrwrs rorHzasync_scoped_session.executes  rc Kywrsrwrs rorHzasync_scoped_session.execute)s r)rrc`K|jj|f|||d|d{S7w)avExecute a statement and return a buffered :class:`_engine.Result` object. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. seealso:: :meth:`_orm.Session.execute` - main documentation for execute rrrN)rurHrmrrrrr~s rorHzasync_scoped_session.execute5sF0+T]]**  /)       %.,.c<|jj||S)aExpire the attributes on an instance. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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` )attribute_names)rurI)rmrrs rorIzasync_scoped_session.expireUsh}}##Ho#NNrqc6|jjS)a%Expires all persistent instances within this Session. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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` )rurJrts rorJzasync_scoped_session.expire_allsZ}}''))rqc8|jj|S)aRemove the `instance` from this ``Session``. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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. )rurKrs rorKzasync_scoped_session.expunges(}}$$X..rqc6|jjS)aRemove all object instances from this ``Session``. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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``. )rurLrts rorLz async_scoped_session.expunge_alls(}}((**rqcVK|jj|d{S7w)aNFlush all the object changes to the database. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. seealso:: :meth:`_orm.Session.flush` - main documentation for flush )objectsN)rurM)rmrs rorMzasync_scoped_session.flushs&]](((9999s )')c B|jjd|||d|S)a~Return a "bind" to which the synchronous proxied :class:`_orm.Session` is bound. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. 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. )mapperclauserZrw)rurN)rmrrrZr~s rorNzasync_scoped_session.get_binds2l&t}}%% &t 79  rqc<|jj||S)a Return ``True`` if the given instance has locally modified attributes. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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)rurO)rmrrs rorOz async_scoped_session.is_modifiedQs'D}}(( *=)  rqcRK|jjd{S7w)a?Close this Session, using connection invalidation. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. For a complete description, see :meth:`_orm.Session.invalidate`. N)rurPrts rorPzasync_scoped_session.invalidates!]]--////rloadoptionscZK|jj|||d{S7w)aCopy the state of a given instance into a corresponding instance within this :class:`_asyncio.AsyncSession`. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. seealso:: :meth:`_orm.Session.merge` - main documentation for merge rN)rurQ)rmrrrs rorQzasync_scoped_session.merges*,]]((g(NNNN "+)+cZK|jj|||d{S7w)aoExpire and refresh the attributes on the given instance. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. 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 )rwith_for_updateN)rurR)rmrrrs rorRzasync_scoped_session.refreshs74]]** +++    rcRK|jjd{S7w)aaRollback the current transaction in progress. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. seealso:: :meth:`_orm.Session.rollback` - main documentation for "rollback" N)rurSrts rorSzasync_scoped_session.rollbacks!]]++----rc Kywrsrwrs rorTzasync_scoped_session.scalars rc Kywrsrwrs rorTzasync_scoped_session.scalars rc`K|jj|f|||d|d{S7w)aRExecute a statement and return a scalar result. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. seealso:: :meth:`_orm.Session.scalar` - main documentation for scalar rN)rurTrs rorTzasync_scoped_session.scalarsF.*T]]))  /)       rc Kywrsrwrs rorUzasync_scoped_session.scalars# rc Kywrsrwrs rorUzasync_scoped_session.scalars.s  rc`K|jj|f|||d|d{S7w)aExecute a statement and return scalar results. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. :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 rN)rurUrs rorUzasync_scoped_session.scalars9sG@+T]]**  /)       rFrpopulate_existingridentity_tokenrc fK|jj|||||||d{}|S7w)a}Return an instance based on the given primary key identifier, or ``None`` if not found. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. seealso:: :meth:`_orm.Session.get` - main documentation for get rN)rurV) rmentityidentrrrrrresults rorVzasync_scoped_session.getasG6}}((  /+)/)    s &1/1c bK|jj|||||||d{S7w)a Return an instance based on the given primary key identifier, or raise an exception if not found. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. Raises ``sqlalchemy.orm.exc.NoResultFound`` if the query selects no rows. ..versionadded: 2.0.22 .. seealso:: :meth:`_orm.Session.get_one` - main documentation for get_one rN)rurW)rmrrrrrrrs rorWzasync_scoped_session.get_onesC>]]**  /+)/+    s &/-/c Kywrsrwrs rorXzasync_scoped_session.streams rc Kywrsrwrs rorXzasync_scoped_session.streamrrc`K|jj|f|||d|d{S7w)aExecute a statement and return a streaming :class:`_asyncio.AsyncResult` object. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. rN)rurXrs rorXzasync_scoped_session.streamsF(*T]]))  /)       rc Kywrsrwrs rorYz#async_scoped_session.stream_scalarss !$rc Kywrsrwrs rorYz#async_scoped_session.stream_scalarss "%rc`K|jj|f|||d|d{S7w)a Execute a statement and return a stream of scalar results. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. :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 rN)rurYrs rorYz#async_scoped_session.stream_scalarssF:2T]]11  /)       rc.|jjS)zProxy for the :attr:`_asyncio.AsyncSession.bind` attribute on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. rurZrts rorZzasync_scoped_session.binds}}!!!rqc&||j_yrsrrmattrs rorZzasync_scoped_session.bind&s! rqc.|jjS)aThe set of all persistent instances considered dirty. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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. )rur[rts ror[zasync_scoped_session.dirty*sJ}}"""rqc.|jjS)aThe set of all instances marked as 'deleted' within this ``Session`` .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. container:: class_bases Proxied for the :class:`_orm.Session` class on behalf of the :class:`_asyncio.AsyncSession` class. )rur\rts ror\zasync_scoped_session.deletedQs"}}$$$rqc.|jjS)aThe set of all instances marked as 'new' within this ``Session``. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. container:: class_bases Proxied for the :class:`_orm.Session` class on behalf of the :class:`_asyncio.AsyncSession` class. )rur]rts ror]zasync_scoped_session.newds"}}   rqc.|jjS)a<Proxy for the :attr:`_orm.Session.identity_map` attribute on behalf of the :class:`_asyncio.AsyncSession` class. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. rur^rts ror^z!async_scoped_session.identity_mapws}})))rqc&||j_yrsrrs ror^z!async_scoped_session.identity_maps%) "rqc.|jjS)aTrue if this :class:`.Session` not in "partial rollback" state. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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` )rur_rts ror_zasync_scoped_session.is_activesR}}&&&rqc.|jjS)a9Proxy for the :attr:`_orm.Session.autoflush` attribute on behalf of the :class:`_asyncio.AsyncSession` class. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. rur`rts ror`zasync_scoped_session.autoflushs}}&&&rqc&||j_yrsrrs ror`zasync_scoped_session.autoflushs"& rqc.|jjS)aReturn a context manager that disables autoflush. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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. )rurarts roraz!async_scoped_session.no_autoflushsB}})))rqc.|jjS)aA user-modifiable dictionary. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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. )rurbrts rorbzasync_scoped_session.infos0}}!!!rqcFKtjd{S7w)aClose all :class:`_asyncio.AsyncSession` sessions. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. deprecated:: 2.0 The :meth:`.AsyncSession.close_all` method is deprecated and will be removed in a future release. Please refer to :func:`_asyncio.close_all_sessions`. N)rr9)clss ror9zasync_scoped_session.close_alls"++----s !!c,tj|S)aReturn the :class:`.Session` to which an object belongs. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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`. )rr:)rrs ror:z#async_scoped_session.object_sessions(**844rq)rrowrc6tj|||||S)aReturn an identity key. .. container:: class_bases Proxied for the :class:`_asyncio.AsyncSession` class on behalf of the :class:`_asyncio.scoping.async_scoped_session` class. .. 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_rrrr)rr;)rrrrrrs ror;z!async_scoped_session.identity_key*s&8(()   rq)rjrirnzCallable[[], Any])returnr)r~rrr)rrrNone)rr)robjectrbool)rzIterator[object])T)rrrrrr)rzIterable[object]rr)rr )NN)rOptional[_BindArguments]rz%Optional[CoreExecuteOptionsParameter]r~rrr)rrrrrs)rTypedReturnsRows[_T]rOptional[_CoreAnyExecuteParams]rr,rrr Optional[Any]rrrz Result[_T])rr3rrrr,rrrrrrrzCursorResult[Any])rr2rrrr,rrrrrrr Result[Any]) rr2rrrr,rrr~rrr)rrrOptional[Iterable[str]]rr)rzOptional[Sequence[Any]]rr)NNN) rzOptional[_EntityBindKey[_O]]rzOptional[ClauseElement]rZzOptional[_SessionBind]r~rrzUnion[Engine, Connection])rrrrrr)rr+rrrOptional[Sequence[ORMOption]]rr+)rrrrrr5rr) rTypedReturnsRows[Tuple[_T]]rrrr,rrr~rrz Optional[_T]) rr2rrrr,rrr~rrr) rrrrrr,rrr~rrzScalarResult[_T]) rr2rrrr,rrr~rrzScalarResult[Any])r_EntityBindKey[_O]rr0rrrrrr5rrrr,rzUnion[_O, None])rrrr0rrrrrr5rrrr,rr+) rrrrrr,rrr~rrzAsyncResult[_T]) rr2rrrr,rrr~rrzAsyncResult[Any]) rrrrrr,rrr~rrzAsyncScalarResult[_T]) rr2rrrr,rrr~rrzAsyncScalarResult[Any])rr)rrrr)rrrzOptional[Session]) rzOptional[Type[Any]]rzUnion[Any, Tuple[Any, ...]]rrrz%Optional[Union[Row[Any], RowMapping]]rrrz_IdentityKeyType[Any]);__name__ __module__ __qualname____doc__r|__annotations__rppropertyrurrrr<r=r>r?r@rArBrCrDrErFrGr r EMPTY_DICTrHrIrJrKrLrMrNrOrPrQrRrSrTrUrVrWrXrYrZsetterr[r\r]r^r_r`rarb classmethodr9r:r;rwrqrorhrhBs{ fN,,:"!C0C%C(@1" "4,((,&&8P08%:,2+.+2,&48CG  0  A      D4,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     BLP4O4O1H4O 4Ol-*^/,+,:&04*.'+ X ,X (X % X  X # X v=AD D 59D D L 0$15 OO O / O O648.2   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      37& 9=37 & & 0& 6 & 1 & &  & Z26"'.2(,8<$"$#$ / $  $,$&$6$ $V26"'.2(,8<' "' #' / '  ' ,' &' 6'  ' R37 9=37 '0 6  1  37 9=37 0 6  1  37 9=37   0 6  1     837$ 9=37 $.$0$ 6 $ 1 $$ $$37% 9=37 %%0% 6 % 1 %% %%37# 9=37 # # 0# 6 # 1 # #  # J"" [[""$#$#L%%$!!$ * ***('('T ' ''' * *D""2 . .55*'+-1! #'59(,! #! +!  ! 3 ! &!  ! ! rqrhN)D __future__rtypingrrrrrr r r r r rrrsessionrrrrryr orm.sessionrrrrrenginerrrrr r!r"r#r$r%r&engine.interfacesr'r( engine.resultr) orm._typingr*r+r,orm.interfacesr-r.r/r0r1sql.baser2sql.dmlr3 sql.elementsr4sql.selectabler5r6r7rhrwrqror s# '!"("#'#)0$&  $:@-/!9+--2+&%-42 T$4@ @  %ga1dX 73<X e1dX rq