U ÃÏ a^Rã@sˆddlZddlmZddlmZddlmZddlmZddlmZGdd „d eƒZGd d „d eƒZ Gd d „d eƒZ Gdd„deƒZ dS)éNé)Ú_NO_ROW)Ú FilterResult)Ú FrozenResult)Ú MergedResult)Úgreenlet_spawnc@seZdZdd„ZdS)Ú AsyncCommoncÃst|jjƒIdHdS)zClose this result.N)rÚ _real_resultÚclose©Úself©r ú^C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\ext\asyncio\result.pyr szAsyncCommon.closeN)Ú__name__Ú __module__Ú __qualname__r r r r rrsrc@s¸eZdZdZdd„Zdd„Zd,dd„Zd d „Zd-d d „Zd d„Z d.dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd/d(d)„Zd*d+„ZdS)0Ú AsyncResultalAn asyncio wrapper around a :class:`_result.Result` object. The :class:`_asyncio.AsyncResult` only applies to statement executions that use a server-side cursor. It is returned only from the :meth:`_asyncio.AsyncConnection.stream` and :meth:`_asyncio.AsyncSession.stream` methods. .. note:: As is the case with :class:`_engine.Result`, this object is used for ORM results returned by :meth:`_asyncio.AsyncSession.execute`, which can yield instances of ORM mapped objects either individually or within tuple-like rows. Note that these result objects do not deduplicate instances or rows automatically as is the case with the legacy :class:`_orm.Query` object. For in-Python de-duplication of instances or rows, use the :meth:`_asyncio.AsyncResult.unique` modifier method. .. versionadded:: 1.4 cCs6||_|j|_|j|_d|jkr2| d|jd¡dS)NZ _row_getter)r Ú _metadataÚ_unique_filter_stateÚ__dict__Z_set_memoized_attribute)r Ú real_resultr r rÚ__init__-s ÿzAsyncResult.__init__cCs|jjS)zpReturn the :meth:`_engine.Result.keys` collection from the underlying :class:`_engine.Result`. ©rÚkeysr r r rr:szAsyncResult.keysNcCstƒ|f|_|S)zéApply unique filtering to the objects returned by this :class:`_asyncio.AsyncResult`. Refer to :meth:`_engine.Result.unique` in the synchronous SQLAlchemy API for a complete behavioral description. ©Úsetr©r Zstrategyr r rÚuniqueAs zAsyncResult.uniquecGs | |¡S)zÇEstablish the columns that should be returned in each row. Refer to :meth:`_engine.Result.columns` in the synchronous SQLAlchemy API for a complete behavioral description. ©Z_column_slices©r Zcol_expressionsr r rÚcolumnsMszAsyncResult.columnscCs,|j}t|||ƒIdH}|r(|Vqq(qdS)aŸIterate through sub-lists of rows of the size given. An async iterator is returned:: async def scroll_results(connection): result = await connection.stream(select(users_table)) async for partition in result.partitions(100): print("list of rows: %s" % partition) .. seealso:: :meth:`_engine.Result.partitions` N©Ú_manyrow_getterr©r ÚsizeÚgetterÚ partitionr r rÚ partitionsWs zAsyncResult.partitionscÃs&t|j|ƒIdH}|tkrdS|SdS)aÒFetch one row. When all rows are exhausted, returns None. This method is provided for backwards compatibility with SQLAlchemy 1.x.x. To fetch the first row of a result only, use the :meth:`_engine.Result.first` method. To iterate through all rows, iterate the :class:`_engine.Result` object directly. :return: a :class:`.Row` object if no filters are applied, or None if no rows remain. N©rÚ_onerow_getterr©r Úrowr r rÚfetchoneqszAsyncResult.fetchonecÃst|j||ƒIdHS)a”Fetch many rows. When all rows are exhausted, returns an empty list. This method is provided for backwards compatibility with SQLAlchemy 1.x.x. To fetch rows in groups, use the :meth:`._asyncio.AsyncResult.partitions` method. :return: a list of :class:`.Row` objects. .. seealso:: :meth:`_asyncio.AsyncResult.partitions` N©rr"©r r$r r rÚ fetchmany‡szAsyncResult.fetchmanycÃst|jƒIdHS)zÄReturn all rows in a list. Closes the result set after invocation. Subsequent invocations will return an empty list. :return: a list of :class:`.Row` objects. N©rZ_allrowsr r r rÚallœs zAsyncResult.allcCs|S©Nr r r r rÚ __aiter__¨szAsyncResult.__aiter__cÃs*t|j|ƒIdH}|tkr"tƒ‚n|SdSr2©rr)rÚStopAsyncIterationr*r r rÚ __anext__«szAsyncResult.__anext__cÃst|jdddƒIdHS)a–Fetch the first row or None if no row is present. Closes the result set and discards remaining rows. .. note:: This method returns one **row**, e.g. tuple, by default. To return exactly one single scalar value, that is, the first column of the first row, use the :meth:`_asyncio.AsyncResult.scalar` method, or combine :meth:`_asyncio.AsyncResult.scalars` and :meth:`_asyncio.AsyncResult.first`. :return: a :class:`.Row` object, or None if no rows remain. .. seealso:: :meth:`_asyncio.AsyncResult.scalar` :meth:`_asyncio.AsyncResult.one` FN©rZ _only_one_rowr r r rÚfirst²szAsyncResult.firstcÃst|jdddƒIdHS)aÒReturn at most one result or raise an exception. Returns ``None`` if the result has no rows. Raises :class:`.MultipleResultsFound` if multiple rows are returned. .. versionadded:: 1.4 :return: The first :class:`.Row` or None if no row is available. :raises: :class:`.MultipleResultsFound` .. seealso:: :meth:`_asyncio.AsyncResult.first` :meth:`_asyncio.AsyncResult.one` TFNr7r r r rÚ one_or_noneÉszAsyncResult.one_or_nonecÃst|jdddƒIdHS)a6Return exactly one scalar result or raise an exception. This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and then :meth:`_asyncio.AsyncResult.one`. .. seealso:: :meth:`_asyncio.AsyncResult.one` :meth:`_asyncio.AsyncResult.scalars` TNr7r r r rÚ scalar_oneßs zAsyncResult.scalar_onecÃst|jdddƒIdHS)a6Return exactly one or no scalar result. This is equivalent to calling :meth:`_asyncio.AsyncResult.scalars` and then :meth:`_asyncio.AsyncResult.one_or_none`. .. seealso:: :meth:`_asyncio.AsyncResult.one_or_none` :meth:`_asyncio.AsyncResult.scalars` TFNr7r r r rÚscalar_one_or_noneîs zAsyncResult.scalar_one_or_nonecÃst|jdddƒIdHS)a‚Return exactly one row or raise an exception. Raises :class:`.NoResultFound` if the result returns no rows, or :class:`.MultipleResultsFound` if multiple rows would be returned. .. note:: This method returns one **row**, e.g. tuple, by default. To return exactly one single scalar value, that is, the first column of the first row, use the :meth:`_asyncio.AsyncResult.scalar_one` method, or combine :meth:`_asyncio.AsyncResult.scalars` and :meth:`_asyncio.AsyncResult.one`. .. versionadded:: 1.4 :return: The first :class:`.Row`. :raises: :class:`.MultipleResultsFound`, :class:`.NoResultFound` .. seealso:: :meth:`_asyncio.AsyncResult.first` :meth:`_asyncio.AsyncResult.one_or_none` :meth:`_asyncio.AsyncResult.scalar_one` TFNr7r r r rÚoneýszAsyncResult.onecÃst|jdddƒIdHS)a§Fetch the first column of the first row, and close the result set. Returns None if there are no rows to fetch. No validation is performed to test if additional rows remain. After calling this method, the object is fully closed, e.g. the :meth:`_engine.CursorResult.close` method will have been called. :return: a Python scalar value , or None if no rows remain. FTNr7r r r rÚscalarszAsyncResult.scalarcÃstt|ƒIdHS)aReturn a callable object that will produce copies of this :class:`_asyncio.AsyncResult` when invoked. The callable object returned is an instance of :class:`_engine.FrozenResult`. This is used for result set caching. The method must be called on the result when it has been unconsumed, and calling the method will consume the result fully. When the :class:`_engine.FrozenResult` is retrieved from a cache, it can be called any number of times where it will produce a new :class:`_engine.Result` object each time against its stored set of rows. .. seealso:: :ref:`do_orm_execute_re_executing` - example usage within the ORM to implement a result-set cache. N)rrr r r rÚfreeze,szAsyncResult.freezecGst|j|f|ƒS)aáMerge this :class:`_asyncio.AsyncResult` with other compatible result objects. The object returned is an instance of :class:`_engine.MergedResult`, which will be composed of iterators from the given result objects. The new result will use the metadata from this result object. The subsequent result objects must be against an identical set of result / cursor metadata, otherwise the behavior is undefined. )rr)r Zothersr r rÚmergeCszAsyncResult.mergercCs t|j|ƒS)a>Return an :class:`_asyncio.AsyncScalarResult` filtering object which will return single elements rather than :class:`_row.Row` objects. Refer to :meth:`_result.Result.scalars` in the synchronous SQLAlchemy API for a complete behavioral description. :param index: integer or row key indicating the column to be fetched from each row, defaults to ``0`` indicating the first column. :return: a new :class:`_asyncio.AsyncScalarResult` filtering object referring to this :class:`_asyncio.AsyncResult` object. )ÚAsyncScalarResultr )r Úindexr r rÚscalarsSszAsyncResult.scalarscCs t|jƒS)aApply a mappings filter to returned rows, returning an instance of :class:`_asyncio.AsyncMappingResult`. When this filter is applied, fetching rows will return :class:`.RowMapping` objects instead of :class:`.Row` objects. Refer to :meth:`_result.Result.mappings` in the synchronous SQLAlchemy API for a complete behavioral description. :return: a new :class:`_asyncio.AsyncMappingResult` filtering object referring to the underlying :class:`_result.Result` object. )ÚAsyncMappingResultr r r r rÚmappingscszAsyncResult.mappings)N)N)N)r)rrrÚ__doc__rrrr r'r,r/r1r3r6r8r9r:r;r<r=r>r?rBrDr r r rrs*      rc@sreZdZdZdZdd„Zddd„Zddd „Zd d „Zdd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)r@a—A wrapper for a :class:`_asyncio.AsyncResult` that returns scalar values rather than :class:`_row.Row` values. The :class:`_asyncio.AsyncScalarResult` object is acquired by calling the :meth:`_asyncio.AsyncResult.scalars` method. Refer to the :class:`_result.ScalarResult` object in the synchronous SQLAlchemy API for a complete behavioral description. .. versionadded:: 1.4 FcCsD||_|jr|j|_d|_n|j |g¡|_t d¡|_|j|_dS©Nr)r Ú_source_supports_scalarsrÚ_post_creational_filterÚ_reduceÚoperatorÚ itemgetterr)r rrAr r rr…s zAsyncScalarResult.__init__NcCstƒ|f|_|S)z±Apply unique filtering to the objects returned by this :class:`_asyncio.AsyncScalarResult`. See :meth:`_asyncio.AsyncResult.unique` for usage details. rrr r rr‘s zAsyncScalarResult.uniquecCs,|j}t|||ƒIdH}|r(|Vqq(qdS)zäIterate through sub-lists of elements of the size given. Equivalent to :meth:`_asyncio.AsyncResult.partitions` except that scalar values, rather than :class:`_result.Row` objects, are returned. Nr!r#r r rr'›s zAsyncScalarResult.partitionscÃst|jƒIdHS)z@A synonym for the :meth:`_asyncio.AsyncScalarResult.all` method.Nr0r r r rÚfetchall­szAsyncScalarResult.fetchallcÃst|j||ƒIdHS)z¾Fetch many objects. Equivalent to :meth:`_asyncio.AsyncResult.fetchmany` except that scalar values, rather than :class:`_result.Row` objects, are returned. Nr-r.r r rr/²szAsyncScalarResult.fetchmanycÃst|jƒIdHS)zÈReturn all scalar values in a list. Equivalent to :meth:`_asyncio.AsyncResult.all` except that scalar values, rather than :class:`_result.Row` objects, are returned. Nr0r r r rr1¼szAsyncScalarResult.allcCs|Sr2r r r r rr3ÆszAsyncScalarResult.__aiter__cÃs*t|j|ƒIdH}|tkr"tƒ‚n|SdSr2r4r*r r rr6ÉszAsyncScalarResult.__anext__cÃst|jdddƒIdHS)zÞFetch the first object or None if no object is present. Equivalent to :meth:`_asyncio.AsyncResult.first` except that scalar values, rather than :class:`_result.Row` objects, are returned. FNr7r r r rr8ÐszAsyncScalarResult.firstcÃst|jdddƒIdHS)zÝReturn at most one object or raise an exception. Equivalent to :meth:`_asyncio.AsyncResult.one_or_none` except that scalar values, rather than :class:`_result.Row` objects, are returned. TFNr7r r r rr9ÚszAsyncScalarResult.one_or_nonecÃst|jdddƒIdHS)zÕReturn exactly one object or raise an exception. Equivalent to :meth:`_asyncio.AsyncResult.one` except that scalar values, rather than :class:`_result.Row` objects, are returned. TFNr7r r r rr<äszAsyncScalarResult.one)N)N)N)rrrrEÚ_generate_rowsrrr'rLr/r1r3r6r8r9r<r r r rr@us      r@c@s”eZdZdZdZe d¡Zdd„Zdd„Z d!d d „Z d d „Z d"d d„Z dd„Z dd„Zd#dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „ZdS)$rCa¡A wrapper for a :class:`_asyncio.AsyncResult` that returns dictionary values rather than :class:`_engine.Row` values. The :class:`_asyncio.AsyncMappingResult` object is acquired by calling the :meth:`_asyncio.AsyncResult.mappings` method. Refer to the :class:`_result.MappingResult` object in the synchronous SQLAlchemy API for a complete behavioral description. .. versionadded:: 1.4 TÚ_mappingcCs0||_|j|_|j|_|jr,|j dg¡|_dSrF)r rrrGrI)r Úresultr r rrs zAsyncMappingResult.__init__cCs|jjS)a¿Return an iterable view which yields the string keys that would be represented by each :class:`.Row`. The view also can be tested for key containment using the Python ``in`` operator, which will test both for the string keys represented in the view, as well as for alternate keys such as column objects. .. versionchanged:: 1.4 a key view object is returned rather than a plain list. rr r r rrs zAsyncMappingResult.keysNcCstƒ|f|_|S)z²Apply unique filtering to the objects returned by this :class:`_asyncio.AsyncMappingResult`. See :meth:`_asyncio.AsyncResult.unique` for usage details. rrr r rrs zAsyncMappingResult.uniquecGs | |¡S)z:Establish the columns that should be returned in each row.rrr r rr !szAsyncMappingResult.columnscCs,|j}t|||ƒIdH}|r(|Vqq(qdS)zåIterate through sub-lists of elements of the size given. Equivalent to :meth:`_asyncio.AsyncResult.partitions` except that mapping values, rather than :class:`_result.Row` objects, are returned. Nr!r#r r rr'%s zAsyncMappingResult.partitionscÃst|jƒIdHS)zAA synonym for the :meth:`_asyncio.AsyncMappingResult.all` method.Nr0r r r rrL7szAsyncMappingResult.fetchallcÃs&t|j|ƒIdH}|tkrdS|SdS)z¼Fetch one object. Equivalent to :meth:`_asyncio.AsyncResult.fetchone` except that mapping values, rather than :class:`_result.Row` objects, are returned. Nr(r*r r rr,<s zAsyncMappingResult.fetchonecÃst|j||ƒIdHS)z¿Fetch many objects. Equivalent to :meth:`_asyncio.AsyncResult.fetchmany` except that mapping values, rather than :class:`_result.Row` objects, are returned. Nr-r.r r rr/Ks zAsyncMappingResult.fetchmanycÃst|jƒIdHS)zÉReturn all scalar values in a list. Equivalent to :meth:`_asyncio.AsyncResult.all` except that mapping values, rather than :class:`_result.Row` objects, are returned. Nr0r r r rr1Vs zAsyncMappingResult.allcCs|Sr2r r r r rr3aszAsyncMappingResult.__aiter__cÃs*t|j|ƒIdH}|tkr"tƒ‚n|SdSr2r4r*r r rr6dszAsyncMappingResult.__anext__cÃst|jdddƒIdHS)zàFetch the first object or None if no object is present. Equivalent to :meth:`_asyncio.AsyncResult.first` except that mapping values, rather than :class:`_result.Row` objects, are returned. FNr7r r r rr8ks zAsyncMappingResult.firstcÃst|jdddƒIdHS)zÞReturn at most one object or raise an exception. Equivalent to :meth:`_asyncio.AsyncResult.one_or_none` except that mapping values, rather than :class:`_result.Row` objects, are returned. TFNr7r r r rr9vszAsyncMappingResult.one_or_nonecÃst|jdddƒIdHS)zÖReturn exactly one object or raise an exception. Equivalent to :meth:`_asyncio.AsyncResult.one` except that mapping values, rather than :class:`_result.Row` objects, are returned. TFNr7r r r rr<€szAsyncMappingResult.one)N)N)N)rrrrErMrJÚ attrgetterrHrrrr r'rLr,r/r1r3r6r8r9r<r r r rrCïs"        rC) rJZ engine.resultrrrrZutil.concurrencyrrrr@rCr r r rÚs     _z