L i/dZddlmZddlmZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl!m#Z#ddl!m$Z$dd l m%Z%dd!l m&Z&dd"l'm(Z(dd#l)m*Z*dd$l)m+Z+ej0se(sdd%l,m-Z-ndd%l.m-Z-ej0r dd&l/m0Z0dd'l1m2Z2ee3d(fZ4ee4e5fZ6e Z7ee4e7fZ8eee ee fZ9 ee d)fZ: ed*e9+Z;ed,e +Z<ed-ee d)f+Z=ee;e:fZ> eee e fZ?eed.Z@e ee gee fZAe e ge fZBeee eeBfZCGd/d0ZDGd1d2eje ZFGd3d4eDZG dO dPd5ZHGd6d7eZIeIjZJGd8d9e$e e;ZKGd:d;ZLGd<d=eLeKee=ZMGd>d?eKe;ZNGd@dAeNe;ZOGdBdCeNe;e jZQGdDdEeLeNeZRGdFdGe e=ZSGdHdIeMe=ZTdQdJZUGdKdLeTe=ZVGdMdNeTe=ZWy)Rz%Define generic result set constructs.) annotations)EnumN)Any)Callable)cast)Dict)Generic)Iterable)Iterator)List)Mapping)NoReturn)Optional)overload)Sequence)Set)Tuple) TYPE_CHECKING)TypeVar)Union)Row) RowMapping)exc)util) _generative) HasMemoized)InPlaceGenerative)!HasMemoized_ro_memoized_attribute)NONE_SET)HAS_CYEXTENSION)Literal)Self) tuplegetter)SQLCoreOperations)_ResultProcessorTypezSQLCoreOperations[Any]._R)bound_T_TPz_ResultProcessorType[Any]ceZdZUdZdZdZded<dZded<dZded <d ed <d ed <ded<ded<e d#dZ d$dZ d%dZ e d& d'dZe d& d(dZe d& d)dZ d* d)dZ d+dZ d,dZ d-dZ d.dZd/dZ d* d0dZ d1dZ d2d Zd3d!Ze d4d"Zy)5ResultMetaDataz$Base for metadata about result rows.NOptional[_TupleGetterType] _tuplefilterOptional[Sequence[int]]_translated_indexes(Optional[Sequence[Callable[[Any], Any]]]_unique_filters _KeyMapType_keymap Sequence[str]_keysOptional[_ProcessorsType] _processorsMapping[_KeyType, int] _key_to_indexct|SN) RMKeyViewselfs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/engine/result.pykeyszResultMetaData.keysjs ctr>NotImplementedErrorrAkeys rB_has_keyzResultMetaData._has_keyn !##rDctr>rFr@s rB _for_freezezResultMetaData._for_freezeqrKrDcyr>r.rArIerrraiseerrs rB _key_fallbackzResultMetaData._key_fallbacktsrDcyr>r.rOs rBrRzResultMetaData._key_fallbackys rDcyr>r.rOs rBrRzResultMetaData._key_fallbacks!rDc"|sJt||r>)KeyErrorrOs rBrRzResultMetaData._key_fallbacksxsm$rDctd)NzCambiguous column name logic is implemented for CursorResultMetaDatarF)rArecs rB _raise_for_ambiguous_column_namez/ResultMetaData._raise_for_ambiguous_column_names" #  rDctr>rFrArIrQs rB_index_for_keyzResultMetaData._index_for_key "##rDctr>rFrArCs rB_indexes_for_keysz ResultMetaData._indexes_for_keysr]rDctr>rFr_s rB_metadata_for_keysz!ResultMetaData._metadata_for_keysr]rDctr>rFr_s rB_reducezResultMetaData._reducerKrDcV|j||}|tj|Syr>)r\operator itemgetter)rArIrQindexs rB_getterzResultMetaData._getters0##C2  &&u- -rDc4|j|}t|Sr>)r`r%)rArCindexess rB_row_as_tuple_getterz#ResultMetaData._row_as_tuple_getters((.G$$rDcf|jDcic]\}}|||||c}}Scc}}wr>)items)rAkeymaprhrIrXs rB_make_key_to_indexz!ResultMetaData._make_key_to_indexs@ #LLN S5z% UO   s-c||jvr|j|j|y|r |j|dy|j|dy#t$r}t |j d|d}~wwxYwNr)r6rYrRrVAttributeErrorargs)rArI attr_errorkes rB_key_not_foundzResultMetaData._key_not_foundsx $,,   1 1$,,s2C D=&&sD1""3- =(4"<=sA A> A99A>cr|jrtj|jry|jSr>)r:r! issupersetr@s rB_effective_processorsz$ResultMetaData._effective_processorss-8#6#6t7G7G#H## #rDreturnr?rIobjectr|boolr|r-).)rIrrPOptional[Exception]rQ Literal[True]r|r)rIrrPrrQzLiteral[False]r|None)rIrrPrrQrr|zOptional[NoReturn]T)rX_KeyMapRecTyper|r)rI _KeyIndexTyperQrr| Optional[int])rCSequence[_KeyIndexType]r| Sequence[int])rCrr|Iterator[_KeyMapRecType])rCrr|r-)rIrrQrr|#Optional[Callable[[Row[Any]], Any]]rCrr|_TupleGetterType)roz Mapping[_KeyType, Sequence[Any]]rhintr|r;)rIrrurr|r)r|r9)__name__ __module__ __qualname____doc__ __slots__r0__annotations__r2r4propertyrCrJrMrrRrYr\r`rbrdrirlrprwrzr.rDrBr-r-]s.I/3L,33707@DO=D  **)) $$LO0r)rAparentks rB__init__zRMKeyView.__init__s& !'?Aa? ?s++c,t|jSr>)lenr8r@s rB__len__zRMKeyView.__len__s4::rDc$dj|S)Nz#{0.__class__.__name__}({0._keys!r}))formatr@s rB__repr__zRMKeyView.__repr__s4;;DAArDc,t|jSr>)iterr8r@s rB__iter__zRMKeyView.__iter__sDJJrDcZt|try|jj|SNF) isinstancerrrJ)rAitems rB __contains__zRMKeyView.__contains__s& dC ||$$T**rDc0t|t|k(Sr>listrAothers rB__eq__zRMKeyView.__eq__E{d4j((rDc0t|t|k7Sr>rrs rB__ne__zRMKeyView.__ne__rrDN)rr-)r|r)r|str)r|z Iterator[str])rrr|r)rrr|r) rrrrrrrrrrrrr.rDrBr?r?s8$I  @B +))rDr?ceZdZUdZdZded< d ddZddZddZdd Z dd Z ddd Z dd Z dd Z ddZy)SimpleResultMetaDataz*result metadata for in-memory collections.)r8r6r:r0r2r4r<r7r8Nc t||_||_||_||_|rDt t |j|D cgc]\}\}} |f| r| ndz||| ff} }}} n-t |jDcgc] \}}|f||dff} }}| D cic]\}} |D]} | | c} } }|_||_|j|jd|_ ycc} }}wcc}}wcc} } }w)Nr.r) rr8r0r2r4 enumeratezipr6r:rpr<) rArCextrar:r0r2r4rhnameextras recs_namesrXrIs rBrzSimpleResultMetaData.__init__s$Z (#6 .  .7s4::u7M-N  *E>D&GvR8D&)J$-TZZ#8E45$+,J 3=MMYT3MSMM &!44T\\1E# Ns C&C-C3c||jvSr>r6rHs rBrJzSimpleResultMetaData._has_key'sdll""rDc|j}|r|jr|j|}t|j|jDcgc]}|j|dc}|Scc}w)Nr)rr4)r4r0rr8r6)rAunique_filtersrIs rBrMz SimpleResultMetaData._for_freeze*sd-- d//!..~>N$ JJ37::>C4<<$Q'>*  >s A, c4|j|jdS)Nr8r2rr@s rB __getstate__z!SimpleResultMetaData.__getstate__7sZZ#'#;#;  rDc`|dr|d}t|}ndx}}|j|d||y)Nr2r8)r2r0)r%r)rAstater2r0s rB __setstate__z!SimpleResultMetaData.__setstate__=sK & '"'(="> &(;}}t\}}}|jr|Dcgc]}|j|}}t|} t||| ||j|j} | Scc}w#t $r*}|j |jd|dYd}~d}~wwxYwcc}w)NrT)rr0r2r:r4)r6rrrr8rVrRrtrr2r%rr:r4) rArCrImetadata_for_keysrvrknew_keysridxtup new_metadatas rBrdzSimpleResultMetaData._reduceds 5  ! '*cmm.C.C'CDJJsO! !$'(9#: 5  # #@GHt//4HGH7#+  '(( 00  9!  5   rwwqz2t 4 4 5Is/B1AB,B1%C',B11 C$: CC$)NNNNN) rCr7rzOptional[Sequence[Any]]r:r9r0r/r2r1r4r3r}r)r|Dict[str, Any])rrr|rr)rIrrQrr|r)rC Sequence[Any]r|r)rCrr|r)rCrr|r-)rrrrrrrrJrMrrr\r`rbrdr.rDrBrrs4I  *.15377;DHFF'F/ F 1 F 5 FBFB#    6 !  ! rDrczt||}tjt||j|j Sr>)r functoolspartialrrzr<)fieldsrrs rB result_tuplers8"&% 0F    VV1163G3G rDceZdZdZy)_NoRowrN)rrr_NO_ROWr.rDrBrrsGrDrceZdZUdZdZded<dZded<ded <dZd ed <dZded <d Z ded<ded<d$dZ d% d&dZ d' d(dZ d)dZ d%d*dZed+dZed,dZd-dZd-dZe d.dZed/dZe d0dZe d1dZe d2dZ d2dZd3d Zd4d!Zed5d"Zej:d6d#Zy)7ResultInternalr.NOptional[Result[Any]] _real_resultTr_generate_rowsOptional[Callable[[Any], Any]]_row_logging_fnz Optional[_UniqueFilterStateType]_unique_filter_state_post_creational_filterFr- _metadata_source_supports_scalarsctr>rFr@s rB_fetchiter_implzResultInternal._fetchiter_implrKrDctr>rFrA hard_closes rB_fetchone_implzResultInternal._fetchone_implr]rDctr>rFrAsizes rB_fetchmany_implzResultInternal._fetchmany_implr]rDctr>rFr@s rB_fetchall_implzResultInternal._fetchall_implrKrDctr>rFrAhards rB _soft_closezResultInternal._soft_closerKrDc  |jr |jn td|}|jr$|jsyt d fd }nt}|j }|j }|j}|j}|r8|js,|r||}tj|||| | d fd }ntj||||}|jr|j| d fd }|S)N Result[Any]c||||fSr>r.)metadata processors key_to_index scalar_obj_procs rB process_rowz/ResultInternal._row_getter..process_rows ! *lZMrDc |Sr>r.)row_make_row_origfixed_tfs rBmake_rowz,ResultInternal._row_getter..make_rows%hsm44rDc |Sr>r.)r_log_row _make_rows rBrz,ResultInternal._row_getter..make_rows #//rD) rr-rr9rr;rrr|zRow[Any])rz_InterimRowType[Row[Any]]r|r() rrrrrrr<rzr0rrr) rA real_resultrrrrtfrrr rrrs @@@@@rB _row_getterzResultInternal._row_getters&     mT*   / /&&, 9#9!$   K>>-- 33  " " k:: ^ 090A0AXz<1NH 5!((Xz<H  & &"22H I 0rDc|j|j|jr|j\dfd }|Sdfd }|S)Nc3K|jD]>}r|n|}r|n|}|vr j|r|}|@ywr>)radd)rAraw_rowobjhashedrpost_creational_filterstrategyuniquess rBiterrowsz1ResultInternal._iterator_getter..iterrowssh#335 G-5)7/7Xc]CF( KK'-4S9I sAAc3lK|jD]}r|n|}r|}|ywr>)r)rArrrrs rBrz1ResultInternal._iterator_getter..iterrowssD#335G-5)7.4S9I s14)rArr| Iterator[_R]r rr_unique_strategy)rArrrrrs @@@@rB_iterator_getterzResultInternal._iterator_gettersP##!%!=!=  $ $ $ 5 5 GX  0 rDcx|j}|J|j}|Dcgc] }|| c}Scc}wr>)r r)rArrowsrs rB _raw_all_rowszResultInternal._raw_all_rowss?#####""$)-.# ...s7c|j}|j}|j}|r|Dcgc] }|| }}n|}|jrS|j\}}|Dcgc]}||r||n|fc}D cgc]\}} | |vr|j | s|} }} n|} |r| Dcgc] }|| } }| Scc}wcc}wcc} }wcc}wr>)rr rrrr) rArrrr made_rowsrrmade_rowsig_row interim_rowss rB_allrowszResultInternal._allrowss!%!=!=##""$ 2673#7I7I  $ $ $ 5 5 GX%. * !!.6*H* %Hg')'++g2F L %L !7C03&s+L78* sB="C=!C*C c|j|j|jr|j\dfd }|Sdfd }|S)Nc|j} |}|tSr|n|}r|n|}|vr-j|r|}|Sr>)rrr) rA_onerowrrrrrrrs rBonerowz-ResultInternal._onerow_getter..onerowOsl--!)C{&.6HSM33;#!W,$#KK/1"8"=C" rDcd|j}|tSr|n|}r|}|Sr>)rr)rAr interim_rowrrs rBr(z-ResultInternal._onerow_getter..onerowdsB))+;"N*2 s .&<[&I &&rD)rArr|zUnion[_NoRow, _R]r)rAr(rrrrs @@@@rB_onerow_getterzResultInternal._onerow_getterDsS##!%!=!=  $ $ $ 5 5 GX # #B  ' rDc|j|j|jr/|j\ dd dfd }|S dfd }|S)Nc|r|Dcgc] }|| }}r fd|D}n d|D}|Dcgc]\}}||vr|j|s|c}}Scc}wcc}}w)Nc32K|]}||fywr>r.).0r!rs rB zEResultInternal._manyrow_getter..filterrows..s !;C8H#56!sc3$K|]}||f ywr>r.)r/r!s rBr0zEResultInternal._manyrow_getter..filterrows..s K((H!5 Ks)r)rrrrrr r!r"s ` rB filterrowsz2ResultInternal._manyrow_getter..filterrows{s| 59:cHSM:D:!GK!I!Ld KI.7)'g-gkk'6J;s A!Acg}|j}||jr |jn td|}|jr|jx}}nB||}t |} J|j  | |t |z }n|}|J|r6||}|sn+|j  | |t |z }|r6 r|Dcgc] } | }}|Scc}wNr)rrr _yield_perrextend) rAnumcollect _manyrowsr  num_requiredrrr2rrrrs rBmanyrowsz0ResultInternal._manyrow_getter..manyrowss%' 00 ; ,,))!-6 #---8-C-CC s(~!$i'333&xxI(+S\'9 #&L&"$\2DNN"8T8WE$'W#5L#*FMNs5c:NGNOsC(c|0|jr |jn td|}|j}|j|}r|Dcgc] }| }}r|Dcgc] }| }}|Scc}wcc}wr4)rrr5r)rAr7r rrrrs rBr;z0ResultInternal._manyrow_getter..manyrowss; ,,))!-6 &00C373G3G3L59:cHSM:D:)CGHC237HDH ;Hs A5"A:) rOptional[Callable[..., _R]]rz List[Any]rz$Optional[Callable[[List[Any]], Any]]rzSet[Any]r|List[_R])rAzResultInternal[_R]r7rr|r>r)rAr;r2rrrrs @@@@@rB_manyrow_getterzResultInternal._manyrow_getterrs##!%!=!=  $ $ $ 5 5 GX 5  ? "     *- (- /<- - - F% ( /<  $rDcyr>r.rAraise_for_second_rowraise_for_nonescalars rB _only_one_rowzResultInternal._only_one_rows rDcyr>r.rAs rBrEzResultInternal._only_one_rows rDcyr>r.rAs rBrEzResultInternal._only_one_rows rDc|j}|d}||rtjdy|r|jr d|_d}n |j } |r||n|}|r|jrZ|j\}}|r||n|} |d} | t} n= |r|| n| } |r| tusJ| || k(r8|| k(r>n|d} | t} | turA|j dtj|rdd|j d|s|j} | r| |}|r|r|dS|S#|j dxYw#|j dxYw) NTrz&No row was found when one was requiredFrz6Multiple rows were found when exactly one was requiredz6Multiple rows were found when one or none was requiredr) rr NoResultFoundrrr rrrrMultipleResultsFoundr) rArBrCrDr(rrrrexisting_row_hashnext_rowrs rBrEzResultInternal._only_one_rows $$.4.E ;''< d33"'D H''H #+(3-C ((%)$9$9!5=HSM3!$*d$;H'#* 9A8H#5x##+7#::#:0HX4FF ( H_$ "T2#&Hw&  d +..%M#   $  '%)%A%A "%,S1 hq6MJu    $  ' 6((d(3s E#EEEE3c$|j|Sr>)rr@s rB _iter_implzResultInternal._iter_implBs$$T**rDcL|j|}|tur t|Sr>)r+r StopIterationrArs rB _next_implzResultInternal._next_implEs&!!$' '>/ !JrDc|jr |jn td|}|jrt|dk7r |jj ||_|j sJ|S)Nrr)rrrrrrdr)rArkr s rB_column_sliceszResultInternal._column_slicesLsg     mT*  33s7|q7H!^^33G>99!<  ..88>>.."nn99'BG#001DgN  rDr|z#Iterator[_InterimRowType[Row[Any]]]Frrr|z#Optional[_InterimRowType[Row[Any]]]r>rrr|List[_InterimRowType[Row[Any]]]r|r_rrr|r)r|r=)r|zCallable[..., Iterator[_R]])r|r>)r|z1Callable[..., Union[Literal[_NoRow._NO_ROW], _R]])r|zCallable[..., List[_R]]) rAzResultInternal[Row[Any]]rBrrCrrDrr|r)rBrrCrrDrr|r()rBrrCrrDrr| Optional[_R]r|rr|r()rkrr|r$)r|_UniqueFilterStateType)rrrrrrrrr _is_cursorrrrrrr r rrr$r+r?rrErPrTrrVrmemoized_attributerr.rDrBrrsI*.L'.ND33=A:A>B;BJ""$"'$$ ,$ %)$!$ ($ $$'9'9v' ' D/ #J'+ :+'+Z'`'`D&"  "&  "   S"SS S  Sj+  ##!$!rDrc$eZdZUdZded<ddZy) _WithKeysr.r-rc.|jjS)akReturn an iterable view which yields the string keys that would be represented by each :class:`_engine.Row`. The keys can represent the labels of the columns returned by a core statement or the names of the orm classes returned by an orm execution. 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. )rrCr@s rBrCz_WithKeys.keys{s"~~"""rDNr{)rrrrrrCr.rDrBririusI#rDricdeZdZUdZdZdZded<dZded<dZd ed <e jZ d ed <d5d Z d6dZ d7dZd8dZed9dZed9dZed:dZed;ddZe d?dZed@dAdZd@dAdZ dB dCdZdDdZdEdZedFdZdFdZdGdZdHd ZdId!Z d; dJd"Z!dKd#Z"dLd$Z#d;dMd%Z$dKd&Z%dLd'Z&dLd(Z'edNd)Z(edOd*Z(dOd+Z(edPd,Z)edQd-Z)dQd.Z)dId/Z*edPd0Z+edOd1Z+dOd2Z+dRd3Z,dSd4Z-y)TResulta\Represent a set of database results. .. versionadded:: 1.4 The :class:`_engine.Result` object provides a completely updated usage model and calling facade for SQLAlchemy Core and SQLAlchemy ORM. In Core, it forms the basis of the :class:`_engine.CursorResult` object which replaces the previous :class:`_engine.ResultProxy` interface. When using the ORM, a higher level object called :class:`_engine.ChunkedIteratorResult` is normally used. .. note:: In SQLAlchemy 1.4 and above, this object is used for ORM results returned by :meth:`_orm.Session.execute`, which can yield instances of ORM mapped objects either individually or within tuple-like rows. Note that the :class:`_engine.Result` object does 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:`_engine.Result.unique` modifier method. .. seealso:: :ref:`tutorial_fetching_rows` - in the :doc:`/tutorial/index` )r__dict__Nz(Optional[Callable[[Row[Any]], Row[Any]]]rFrrrr5zutil.immutabledict[Any, Any] _attributesc||_yr>)r)rAcursor_metadatas rBrzResult.__init__s (rDc|Sr>r.r@s rB __enter__zResult.__enter__ rDc$|jyr>)closerAtype_value tracebacks rB__exit__zResult.__exit__s  rDc(|jdy)aclose this :class:`_engine.Result`. The behavior of this method is implementation specific, and is not implemented by default. The method should generally end the resources in use by the result object and also cause any subsequent iteration or row fetching to raise :class:`.ResourceClosedError`. .. versionadded:: 1.4.27 - ``.close()`` was previously not generally available for all :class:`_engine.Result` classes, instead only being available on the :class:`_engine.CursorResult` returned for Core statement executions. As most other result objects, namely the ones used by the ORM, are proxying a :class:`_engine.CursorResult` in any case, this allows the underlying cursor result to be closed from the outside facade for the case when the ORM query is using the ``yield_per`` execution option where it does not immediately exhaust and autoclose the database cursor. TrJN)rr@s rBruz Result.closes( d#rDctr>rFr@s rB _soft_closedzResult._soft_closeds !##rDct)zkreturn ``True`` if this :class:`_engine.Result` reports .closed .. versionadded:: 1.4.43 rFr@s rBclosedz Result.closed "##rDc||_|S)aConfigure the row-fetching strategy to fetch ``num`` rows at a time. This impacts the underlying behavior of the result when iterating over the result object, or otherwise making use of methods such as :meth:`_engine.Result.fetchone` that return one row at a time. Data from the underlying cursor or other data source will be buffered up to this many rows in memory, and the buffered collection will then be yielded out one row at a time or as many rows are requested. Each time the buffer clears, it will be refreshed to this many rows or as many rows remain if fewer remain. The :meth:`_engine.Result.yield_per` method is generally used in conjunction with the :paramref:`_engine.Connection.execution_options.stream_results` execution option, which will allow the database dialect in use to make use of a server side cursor, if the DBAPI supports a specific "server side cursor" mode separate from its default mode of operation. .. tip:: Consider using the :paramref:`_engine.Connection.execution_options.yield_per` execution option, which will simultaneously set :paramref:`_engine.Connection.execution_options.stream_results` to ensure the use of server side cursors, as well as automatically invoke the :meth:`_engine.Result.yield_per` method to establish a fixed row buffer size at once. The :paramref:`_engine.Connection.execution_options.yield_per` execution option is available for ORM operations, with :class:`_orm.Session`-oriented use described at :ref:`orm_queryguide_yield_per`. The Core-only version which works with :class:`_engine.Connection` is new as of SQLAlchemy 1.4.40. .. versionadded:: 1.4 :param num: number of rows to fetch each time the buffer is refilled. If set to a value below 1, fetches all rows for the next buffer. .. seealso:: :ref:`engine_stream_results` - describes Core behavior for :meth:`_engine.Result.yield_per` :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel` )r5rAr7s rB yield_perzResult.yield_persb rDc(t|f|_|S)aApply unique filtering to the objects returned by this :class:`_engine.Result`. When this filter is applied with no arguments, the rows or objects returned will filtered such that each row is returned uniquely. The algorithm used to determine this uniqueness is by default the Python hashing identity of the whole tuple. In some cases a specialized per-entity hashing scheme may be used, such as when using the ORM, a scheme is applied which works against the primary key identity of returned objects. The unique filter is applied **after all other filters**, which means if the columns returned have been refined using a method such as the :meth:`_engine.Result.columns` or :meth:`_engine.Result.scalars` method, the uniquing is applied to **only the column or columns returned**. This occurs regardless of the order in which these methods have been called upon the :class:`_engine.Result` object. The unique filter also changes the calculus used for methods like :meth:`_engine.Result.fetchmany` and :meth:`_engine.Result.partitions`. When using :meth:`_engine.Result.unique`, these methods will continue to yield the number of rows or objects requested, after uniquing has been applied. However, this necessarily impacts the buffering behavior of the underlying cursor or datasource, such that multiple underlying calls to ``cursor.fetchmany()`` may be necessary in order to accumulate enough objects in order to provide a unique collection of the requested size. :param strategy: a callable that will be applied to rows or objects being iterated, which should return an object that represents the unique value of the row. A Python ``set()`` is used to store these identities. If not passed, a default uniqueness strategy is used which may have been assembled by the source of this :class:`_engine.Result` object. setrrArs rBuniquez Result.uniquesL&)UH$5! rDc$|j|S)aEstablish the columns that should be returned in each row. This method may be used to limit the columns returned as well as to reorder them. The given list of expressions are normally a series of integers or string key names. They may also be appropriate :class:`.ColumnElement` objects which correspond to a given statement construct. .. versionchanged:: 2.0 Due to a bug in 1.4, the :meth:`_engine.Result.columns` method had an incorrect behavior where calling upon the method with just one index would cause the :class:`_engine.Result` object to yield scalar values rather than :class:`_engine.Row` objects. In version 2.0, this behavior has been corrected such that calling upon :meth:`_engine.Result.columns` with a single index will produce a :class:`_engine.Result` object that continues to yield :class:`_engine.Row` objects, which include only a single column. E.g.:: statement = select(table.c.x, table.c.y, table.c.z) result = connection.execute(statement) for z, y in result.columns("z", "y"): ... Example of using the column objects from the statement itself:: for z, y in result.columns( statement.selected_columns.c.z, statement.selected_columns.c.y ): ... .. versionadded:: 1.4 :param \*col_expressions: indicates columns to be returned. Elements may be integer row indexes, string column names, or appropriate :class:`.ColumnElement` objects corresponding to a select construct. :return: this :class:`_engine.Result` object with the modifications given. rVrAcol_expressionss rBcolumnszResult.columns<sZ""?33rDcyr>r.r@s rBscalarszResult.scalarsks>ArDcyr>r.rArhs rBrzResult.scalarsnrDcyr>r.rs rBrzResult.scalarsssFIrDct||S)a@Return a :class:`_engine.ScalarResult` filtering object which will return single elements rather than :class:`_row.Row` objects. E.g.:: >>> result = conn.execute(text("select int_id from table")) >>> result.scalars().all() [1, 2, 3] When results are fetched from the :class:`_engine.ScalarResult` filtering object, the single column-row that would be returned by the :class:`_engine.Result` is instead returned as the column's value. .. versionadded:: 1.4 :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:`_engine.ScalarResult` filtering object referring to this :class:`_engine.Result` object. ) ScalarResultrs rBrzResult.scalarsvs.D%((rDch|jr td|jj||S)zareturn a callable that will retrieve the given key from a :class:`_engine.Row`. .can't use this function in 'only scalars' mode)rrGrrir[s rBrizResult._getters6  ( (%@ ~~%%c844rDcf|jr td|jj|S)zbreturn a callable that will retrieve the given keys from a :class:`_engine.Row`. r)rrGrrlr_s rB _tuple_getterzResult._tuple_getters4  ( (%@ ~~22488rDct|S)aApply a mappings filter to returned rows, returning an instance of :class:`_engine.MappingResult`. When this filter is applied, fetching rows will return :class:`_engine.RowMapping` objects instead of :class:`_engine.Row` objects. .. versionadded:: 1.4 :return: a new :class:`_engine.MappingResult` filtering object referring to this :class:`_engine.Result` object. ) MappingResultr@s rBmappingszResult.mappingssT""rDc|S)zApply a "typed tuple" typing filter to returned rows. The :attr:`_engine.Result.t` attribute is a synonym for calling the :meth:`_engine.Result.tuples` method. .. versionadded:: 2.0 r.r@s rBtzResult.ts  rDc|S)a,Apply a "typed tuple" typing filter to returned rows. This method returns the same :class:`_engine.Result` object at runtime, however annotates as returning a :class:`_engine.TupleResult` object that will indicate to :pep:`484` typing tools that plain typed ``Tuple`` instances are returned rather than rows. This allows tuple unpacking and ``__getitem__`` access of :class:`_engine.Row` objects to by typed, for those cases where the statement invoked itself included typing information. .. versionadded:: 2.0 :return: the :class:`_engine.TupleResult` type at typing time. .. seealso:: :attr:`_engine.Result.t` - shorter synonym :attr:`_engine.Row._t` - :class:`_engine.Row` version r.r@s rBtuplesz Result.tupless 0 rDct)zReturn a safe iterator that yields raw row data. This is used by the :meth:`_engine.Result.merge` method to merge multiple compatible results together. rFr@s rB_raw_row_iteratorzResult._raw_row_iteratorrrDc"|jSr>rPr@s rBrzResult.__iter__  rDc"|jSr>rTr@s rB__next__zResult.__next__rrDc#HK|j} |||}|r|nyw)aIterate through sub-lists of rows of the size given. Each list will be of the size given, excluding the last list to be yielded, which may have a small number of rows. No empty lists will be yielded. The result object is automatically closed when the iterator is fully consumed. Note that the backend driver will usually buffer the entire result ahead of time unless the :paramref:`.Connection.execution_options.stream_results` execution option is used indicating that the driver should not pre-buffer results, if possible. Not all drivers support this option and the option is silently ignored for those who do not. When using the ORM, the :meth:`_engine.Result.partitions` method is typically more effective from a memory perspective when it is combined with use of the :ref:`yield_per execution option `, which instructs both the DBAPI driver to use server side cursors, if available, as well as instructs the ORM loading internals to only build a certain amount of ORM objects from a result at a time before yielding them out. .. versionadded:: 1.4 :param size: indicate the maximum number of rows to be present in each list yielded. If None, makes use of the value set by the :meth:`_engine.Result.yield_per`, method, if it were called, or the :paramref:`_engine.Connection.execution_options.yield_per` execution option, which is equivalent in this regard. If yield_per weren't set, it makes use of the :meth:`_engine.Result.fetchmany` default, which may be backend specific and not well defined. :return: iterator of lists .. seealso:: :ref:`engine_stream_results` :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel` Nr?rArgetter partitions rB partitionszResult.partitionss3b%%tT*I  "c"|jS)z4A synonym for the :meth:`_engine.Result.all` method.r$r@s rBfetchallzResult.fetchall'}}rDc:|j|}|tury|S)aFetch 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:`_engine.Row` object if no filters are applied, or ``None`` if no rows remain. Nr+rrSs rBfetchonezResult.fetchone,s# !!$' '>JrDc&|j||S)aFetch many rows. When all rows are exhausted, returns an empty sequence. This method is provided for backwards compatibility with SQLAlchemy 1.x.x. To fetch rows in groups, use the :meth:`_engine.Result.partitions` method. :return: a sequence of :class:`_engine.Row` objects. .. seealso:: :meth:`_engine.Result.partitions` rrs rB fetchmanyzResult.fetchmanyBs&##D$//rDc"|jS)aReturn all rows in a sequence. Closes the result set after invocation. Subsequent invocations will return an empty sequence. .. versionadded:: 1.4 :return: a sequence of :class:`_engine.Row` objects. .. seealso:: :ref:`engine_stream_results` - How to stream a large result set without loading it completely in python. rr@s rBallz Result.allWs"}}rDc*|jdddS)aFetch 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:`_engine.Result.scalar` method, or combine :meth:`_engine.Result.scalars` and :meth:`_engine.Result.first`. Additionally, in contrast to the behavior of the legacy ORM :meth:`_orm.Query.first` method, **no limit is applied** to the SQL query which was invoked to produce this :class:`_engine.Result`; for a DBAPI driver that buffers results in memory before yielding rows, all rows will be sent to the Python process and all but the first row will be discarded. .. seealso:: :ref:`migration_20_unify_select` :return: a :class:`_engine.Row` object, or None if no rows remain. .. seealso:: :meth:`_engine.Result.scalar` :meth:`_engine.Result.one` FrBrCrDrEr@s rBfirstz Result.firstjs$F!!!&uU"  rDc*|jdddS)aReturn 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:`_engine.Row` or ``None`` if no row is available. :raises: :class:`.MultipleResultsFound` .. seealso:: :meth:`_engine.Result.first` :meth:`_engine.Result.one` TFrrr@s rB one_or_nonezResult.one_or_nones#*!!!%eE"  rDcyr>r.r@s rB scalar_onezResult.scalar_one36rDcyr>r.r@s rBrzResult.scalar_one!$rDc*|jdddS)a*Return exactly one scalar result or raise an exception. This is equivalent to calling :meth:`_engine.Result.scalars` and then :meth:`_engine.ScalarResult.one`. .. seealso:: :meth:`_engine.ScalarResult.one` :meth:`_engine.Result.scalars` Trrr@s rBrzResult.scalar_ones#!!!%d4"  rDcyr>r.r@s rBscalar_one_or_nonezResult.scalar_one_or_nonesEHrDcyr>r.r@s rBrzResult.scalar_one_or_nonerrDc*|jdddS)a0Return exactly one scalar result or ``None``. This is equivalent to calling :meth:`_engine.Result.scalars` and then :meth:`_engine.ScalarResult.one_or_none`. .. seealso:: :meth:`_engine.ScalarResult.one_or_none` :meth:`_engine.Result.scalars` TFrrr@s rBrzResult.scalar_one_or_nones#!!!%eD"  rDc*|jdddS)amReturn exactly one row or raise an exception. Raises :class:`_exc.NoResultFound` if the result returns no rows, or :class:`_exc.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:`_engine.Result.scalar_one` method, or combine :meth:`_engine.Result.scalars` and :meth:`_engine.Result.one`. .. versionadded:: 1.4 :return: The first :class:`_engine.Row`. :raises: :class:`.MultipleResultsFound`, :class:`.NoResultFound` .. seealso:: :meth:`_engine.Result.first` :meth:`_engine.Result.one_or_none` :meth:`_engine.Result.scalar_one` TFrrr@s rBonez Result.ones#:!!!%d5"  rDcyr>r.r@s rBrDz Result.scalars9r.r@s rBrDz Result.scalars rDc*|jdddS)aFetch 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. FTrrr@s rBrDz Result.scalars#!!!&uT"  rDct|S)aReturn a callable object that will produce copies of this :class:`_engine.Result` 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. ) FrozenResultr@s rBfreezez Result.freezes*D!!rDc6t|j|f|zS)aMerge this :class:`_engine.Result` 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. ) MergedResultr)rAotherss rBmergez Result.merge(sDNNTGf,<==rD)rpr-r|r$rwrrxrryrr|rr|rr|rr7rr|r$r>rzOptional[_UniqueFilterType]r|r$rrr|r$)rAResult[Tuple[_T]]r|ScalarResult[_T])rArrhz Literal[0]r|r)r)rhrr|zScalarResult[Any]r)rIrrQrr|rr)r|r)r|zTupleResult[_TP]r|zIterator[_RowData])r|zIterator[Row[_TP]])r|zRow[_TP])rrr|zIterator[Sequence[Row[_TP]]])r|Sequence[Row[_TP]])r|zOptional[Row[_TP]])rrr|r)rArr|r*r|r)rArr| Optional[_T]r| Optional[Any])r|FrozenResult[_TP])rrr|zMergedResult[_TP]).rrrrrrrrr5r immutabledictrnrrrrzrurr}rrrrrrrrirrrrrrrrrrrrrrrrrrDrrr.rDrBrlrls2*I@DO=D%*d* $J $0B0B0B0DK-D)$,$$$$11f&&P-4^AA (2 II)448 5  5,0 5 , 5 9#"  4$!!%)8!8 %8t ,0*&% N 266 $$ "HH 66 " B<<    $".>rDrlceZdZUdZdZded<ded<ddZddZedd Z ddd Z e dd Z e dd Z dd Ze ddZddZ d ddZddZ d d dZy)! FilterResultaZA wrapper for a :class:`_engine.Result` that returns objects other than :class:`_engine.Row` objects, such as dictionaries or scalar objects. :class:`_engine.FilterResult` is the common base for additional result APIs including :class:`_engine.MappingResult`, :class:`_engine.ScalarResult` and :class:`_engine.AsyncResult`. )rrrrrmrrrrc|Sr>r.r@s rBrrzFilterResult.__enter__OrsrDc>|jj|||yr>)rrzrvs rBrzzFilterResult.__exit__Rs ""5%;rDcF|jj||_|S)aConfigure the row-fetching strategy to fetch ``num`` rows at a time. The :meth:`_engine.FilterResult.yield_per` method is a pass through to the :meth:`_engine.Result.yield_per` method. See that method's documentation for usage notes. .. versionadded:: 1.4.40 - added :meth:`_engine.FilterResult.yield_per` so that the method is available on all result set implementations .. seealso:: :ref:`engine_stream_results` - describes Core behavior for :meth:`_engine.Result.yield_per` :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel` )rrrs rBrzFilterResult.yield_perUs"&!--77< rDc<|jj|yNrJ)rrrs rBrzFilterResult._soft_closeks %%4%0rDc.|jjSr>)rr}r@s rBr}zFilterResult._soft_closedns  ---rDc.|jjS)z|Return ``True`` if the underlying :class:`_engine.Result` reports closed .. versionadded:: 1.4.43 )rrr@s rBrzFilterResult.closedrs  '''rDc8|jjy)zUClose this :class:`_engine.FilterResult`. .. versionadded:: 1.4.43 N)rrur@s rBruzFilterResult.close|s !rDc.|jjSr>)rrnr@s rBrnzFilterResult._attributess  ,,,rDc6|jjSr>)rrr@s rBrzFilterResult._fetchiter_impls  0022rDc:|jj|S)NrI)rrrs rBrzFilterResult._fetchone_impls  //:/FFrDc6|jjSr>)rrr@s rBrzFilterResult._fetchall_impls  //11rDNc:|jj|SNr)rrrs rBrzFilterResult._fetchmany_impls  00d0;;rDrrrr\rarr)r|zDict[Any, Any]r[r]r`r>r^)rrrrrrrrrzrrrrr}rrurnrrrrr.rDrBrr9sI<;<*1..(("--3"'GG ,G 2%)<!< (+>q+AD ($/$D$D!rDNc(t|f|_|S)zApply unique filtering to the objects returned by this :class:`_engine.ScalarResult`. See :meth:`_engine.Result.unique` for usage details. rrs rBrzScalarResult.unique&)UH$5! rDc#HK|j} |||}|r|nyw)zIterate through sub-lists of elements of the size given. Equivalent to :meth:`_engine.Result.partitions` except that scalar values, rather than :class:`_engine.Row` objects, are returned. Nrrs rBrzScalarResult.partitionss2%%tT*I rc"|jS):A synonym for the :meth:`_engine.ScalarResult.all` method.rr@s rBrzScalarResult.fetchallrrDc&|j||S)zFetch many objects. Equivalent to :meth:`_engine.Result.fetchmany` except that scalar values, rather than :class:`_engine.Row` objects, are returned. rrs rBrzScalarResult.fetchmanys##D$//rDc"|jS)zReturn all scalar values in a sequence. Equivalent to :meth:`_engine.Result.all` except that scalar values, rather than :class:`_engine.Row` objects, are returned. rr@s rBrzScalarResult.alls}}rDc"|jSr>rr@s rBrzScalarResult.__iter__rrDc"|jSr>rr@s rBrzScalarResult.__next__rrDc*|jdddS)zFetch the first object or ``None`` if no object is present. Equivalent to :meth:`_engine.Result.first` except that scalar values, rather than :class:`_engine.Row` objects, are returned. Frrr@s rBrzScalarResult.first#!!!&uU"  rDc*|jdddS)zReturn at most one object or raise an exception. Equivalent to :meth:`_engine.Result.one_or_none` except that scalar values, rather than :class:`_engine.Row` objects, are returned. TFrrr@s rBrzScalarResult.one_or_none#!!!%eE"  rDc*|jdddS)zReturn exactly one object or raise an exception. Equivalent to :meth:`_engine.Result.one` except that scalar values, rather than :class:`_engine.Row` objects, are returned. TFrrr@s rBrzScalarResult.one#!!!%d5"  rD)r rrhrr>rrrr|zIterator[Sequence[_R]]r| Sequence[_R]rrr|r rcrdr|rb)rrrrrrrrrrrrrrrrrrr.rDrBrrsQ IN;; E$ 0!!      rDrceZdZdZdZeru d ddZddZddZdddZ ddZ dd Z dd Z dd Z dd Zdd ZeddZeddZddZe d dZed!dZd!dZed dZeddZddZyy)" TupleResultaA :class:`_engine.Result` that's typed as returning plain Python tuples instead of rows. Since :class:`_engine.Row` acts like a tuple in every way already, this class is a typing only class, regular :class:`_engine.Result` is still used at runtime. r.Ncy)zIterate through sub-lists of elements of the size given. Equivalent to :meth:`_engine.Result.partitions` except that tuple values, rather than :class:`_engine.Row` objects, are returned. Nr.rs rBrzTupleResult.partitions*s rDcy)zFetch one tuple. Equivalent to :meth:`_engine.Result.fetchone` except that tuple values, rather than :class:`_engine.Row` objects, are returned. Nr.r@s rBrzTupleResult.fetchone6 rDcy)rNr.r@s rBrzTupleResult.fetchall@s rDcy)zFetch many objects. Equivalent to :meth:`_engine.Result.fetchmany` except that tuple values, rather than :class:`_engine.Row` objects, are returned. Nr.rs rBrzTupleResult.fetchmanyDrrDcy)zReturn all scalar values in a sequence. Equivalent to :meth:`_engine.Result.all` except that tuple values, rather than :class:`_engine.Row` objects, are returned. Nr.r@s rBrzTupleResult.allNrrDcyr>r.r@s rBrzTupleResult.__iter__XrDcyr>r.r@s rBrzTupleResult.__next__ZrrDcy)zFetch the first object or ``None`` if no object is present. Equivalent to :meth:`_engine.Result.first` except that tuple values, rather than :class:`_engine.Row` objects, are returned. Nr.r@s rBrzTupleResult.first\s rDcy)zReturn at most one object or raise an exception. Equivalent to :meth:`_engine.Result.one_or_none` except that tuple values, rather than :class:`_engine.Row` objects, are returned. Nr.r@s rBrzTupleResult.one_or_nonegrrDcy)zReturn exactly one object or raise an exception. Equivalent to :meth:`_engine.Result.one` except that tuple values, rather than :class:`_engine.Row` objects, are returned. Nr.r@s rBrzTupleResult.oneqrrDcyr>r.r@s rBrzTupleResult.scalar_one{sr.r@s rBrzTupleResult.scalar_one~s%(rDcy)aBReturn exactly one scalar result or raise an exception. This is equivalent to calling :meth:`_engine.Result.scalars` and then :meth:`_engine.ScalarResult.one`. .. seealso:: :meth:`_engine.ScalarResult.one` :meth:`_engine.Result.scalars` Nr.r@s rBrzTupleResult.scalar_one rDcyr>r.r@s rBrzTupleResult.scalar_one_or_nonerrDcyr>r.r@s rBrzTupleResult.scalar_one_or_nones7:rDcy)aBReturn exactly one or no scalar result. This is equivalent to calling :meth:`_engine.Result.scalars` and then :meth:`_engine.ScalarResult.one_or_none`. .. seealso:: :meth:`_engine.ScalarResult.one_or_none` :meth:`_engine.Result.scalars` Nr.r@s rBrzTupleResult.scalar_one_or_noner rDcyr>r.r@s rBrDzTupleResult.scalarsBErDcyr>r.r@s rBrDzTupleResult.scalarrrDcy)aFetch 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. Nr.r@s rBrDzTupleResult.scalars rDr>r rr r rcrd)rATupleResult[Tuple[_T]]r|r*r)rAr'r|rr)rrrrrrrrrrrrrrrrrrrrDr.rDrBrrsI)- %  #      0%    ? ? ( (   (      : :  E E $ $ KrDrceZdZdZdZdZejdZddZ dddZ ddZ d dd Z dd Z dd Zddd Zdd ZddZddZddZddZddZy)rzA wrapper for a :class:`_engine.Result` that returns dictionary values rather than :class:`_engine.Row` values. The :class:`_engine.MappingResult` object is acquired by calling the :meth:`_engine.Result.mappings` method. r.T_mappingc||_|j|_|j|_|jr"|jj dg|_yyrr)rrrrrdrAresults rBrzMappingResult.__init__sK"$*$?$?!))  * *!^^33QC8DN +rDNc(t|f|_|S)zApply unique filtering to the objects returned by this :class:`_engine.MappingResult`. See :meth:`_engine.Result.unique` for usage details. rrs rBrzMappingResult.uniquerrDc$|j|S)z:Establish the columns that should be returned in each row.rrs rBrzMappingResult.columnss""?33rDc#HK|j} |||}|r|nyw)zIterate through sub-lists of elements of the size given. Equivalent to :meth:`_engine.Result.partitions` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned. Nrrs rBrzMappingResult.partitionss2%%tT*I rc"|jS)z;A synonym for the :meth:`_engine.MappingResult.all` method.rr@s rBrzMappingResult.fetchallrrDc:|j|}|tury|S)zFetch one object. Equivalent to :meth:`_engine.Result.fetchone` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned. NrrSs rBrzMappingResult.fetchones#!!$' '>JrDc&|j||S)zFetch many objects. Equivalent to :meth:`_engine.Result.fetchmany` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned. rrs rBrzMappingResult.fetchmany s##D$//rDc"|jS)zReturn all scalar values in a sequence. Equivalent to :meth:`_engine.Result.all` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned. rr@s rBrzMappingResult.alls}}rDc"|jSr>rr@s rBrzMappingResult.__iter__!rrDc"|jSr>rr@s rBrzMappingResult.__next__$rrDc*|jdddS)zFetch the first object or ``None`` if no object is present. Equivalent to :meth:`_engine.Result.first` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned. Frrr@s rBrzMappingResult.first'rrDc*|jdddS)zReturn at most one object or raise an exception. Equivalent to :meth:`_engine.Result.one_or_none` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned. TFrrr@s rBrzMappingResult.one_or_none4rrDc*|jdddS)zReturn exactly one object or raise an exception. Equivalent to :meth:`_engine.Result.one` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned. TFrrr@s rBrzMappingResult.one@r rD)r,rr>rr)rrr|zIterator[Sequence[RowMapping]])r|Sequence[RowMapping])r|zOptional[RowMapping])rrr|r9)r|zIterator[RowMapping])r|r)rrrrrrrf attrgetterrrrrrrrrrrrrrrr.rDrBrrs|IN1h11*=94 %)! '(  0 !!      rDrcDeZdZUdZded<d dZd dZ d dZd dZy) raRepresents a :class:`_engine.Result` object in a "frozen" state suitable for caching. The :class:`_engine.FrozenResult` object is returned from the :meth:`_engine.Result.freeze` method of any :class:`_engine.Result` object. A new iterable :class:`_engine.Result` object is generated from a fixed set of data each time the :class:`_engine.FrozenResult` is invoked as a callable:: result = connection.execute(query) frozen = result.freeze() unfrozen_result_one = frozen() for row in unfrozen_result_one: print(row) unfrozen_result_two = frozen() rows = unfrozen_result_two.all() # ... etc .. versionadded:: 1.4 .. seealso:: :ref:`do_orm_execute_re_executing` - example usage within the ORM to implement a result-set cache. :func:`_orm.loading.merge_frozen_result` - ORM function to merge a frozen result back into a :class:`_orm.Session`. rdatac|jj|_|j|_|j|_|jrt |j |_y|j|_yr>) rrMrrrnrrr<rr+s rBrzFrozenResult.__init__vs`((446 (.(G(G%!--  ( (V5578DI)DIrDc|jr|jDcgc]}|gc}S|jDcgc] }t|c}Scc}wcc}wr>)rr<r)rAelemrs rB rewrite_rowszFrozenResult.rewrite_rowssC  ( ('+yy1tTF1 1)-3#DI3 323s A Actjt}|j|_|j|_|j|_|jr|Dcgc]}|d c}|_|S||_|Scc}wrr)r__new__rrnrr<)rA tuple_datafrds rB with_new_rowszFrozenResult.with_new_rowsss ! !, /mm ))&*&C&C#  ( (%/0qt0BG !BG 1s A<ct|jt|j}|j|_|j |_|Sr>)IteratorResultrrr<rnrr+s rB__call__zFrozenResult.__call__s@&4 MM4 ?' "--*.*G*G' rDN)r, Result[_TP])r|zSequence[Sequence[Any]])rCrr|r)r|rJ) rrrrrrr@rFrIr.rDrBrrMs4$L *4 ,   rDrceZdZdZdZdZ d ddZeddZdddZ ddZ ddZ dd Z d dd Z dd Z d dd Zy)rHzA :class:`_engine.Result` that gets data from a Python iterator of :class:`_engine.Row` objects or similar row-like data. .. versionadded:: 1.4 FNc<||_||_||_||_yr>)riteratorrawr)rArprMrNrs rBrzIteratorResult.__init__s!)  (@%rDc|jS)z{Return ``True`` if this :class:`_engine.IteratorResult` has been closed .. versionadded:: 1.4.43 ) _hard_closedr@s rBrzIteratorResult.closeds   rDc |rd|_|j|jjdd|i|tg|_|j d|_y)NTrr.)rPrNrrrM_reset_memoizationsr})rArkws rBrzIteratorResult._soft_closesR  $D  88  DHH 1d 1b 1R    " rDc,tjd)NzThis result object is closed.)rResourceClosedErrorr@s rB_raise_hard_closedz!IteratorResult._raise_hard_closeds%%&EFFrDc|jSr>)rMr@s rBrz IteratorResult._raw_row_iterators }}rDcR|jr|j|jSr>)rPrVrMr@s rBrzIteratorResult._fetchiter_impls!     # # %}}rDc|jr|jt|jt}|tur|j |y|Sr)rPrVnextrMrr)rArrs rBrzIteratorResult._fetchone_implsI     # # %4=='* '>   *  -JrDc|jr|j t|j|j S#|j wxYwr>)rPrVrrMrr@s rBrzIteratorResult._fetchall_implsA     # # %  &    D   s AAc|jr|jttj|j d|Srr)rPrVr itertoolsislicerMrs rBrzIteratorResult._fetchmany_impls7     # # %I$$T]]At<==rDr)rpr-rM(Iterator[_InterimSupportsScalarsRowType]rNrrrrr\rrrSrr|r)r|rr)r|r_r]r`r>r^)rrrrrPr}rrrrrVrrrrrr.rDrBrHrHsLL &*). A' A; A# A #' A!!!G "'   , %)>!> (>rDrHc>ttgtgSr>)rHrrr.rDrB null_resultrbs .r2DH ==rDcpeZdZdZ d ddZeddZd d fd Z d d fd ZxZ S) ChunkedIteratorResultaAn :class:`_engine.IteratorResult` that works from an iterator-producing callable. The given ``chunks`` argument is a function that is given a number of rows to return in each chunk, or ``None`` for all rows. The function should then return an un-consumed iterator of lists, each list of the requested size. The function can be called at any time again, in which case it should continue from the same result set but adjust the chunk size as given. .. versionadded:: 1.4 c||_||_||_||_tj j |jd|_||_yr>) rchunksrrNr]chain from_iterablerMdynamic_yield_per)rArprfsource_supports_scalarsrNris rBrzChunkedIteratorResult.__init__ sH) (?%!55dkk$6GH !2rDcz||_tjj|j ||_|Sr>)r5r]rgrhrfrMrs rBrzChunkedIteratorResult.yield_per s/!55dkk#6FG  rDc 8t|dd|i|d|_y)NrcgSr>r.rs rBz3ChunkedIteratorResult._soft_close..# s2rDr.)superrrf)rArrSrs rBrz!ChunkedIteratorResult._soft_close! s ,,,% rDc|jr3tjj|j ||_t ||Sr)rir]rgrhrfrMror)rArrs rBrz%ChunkedIteratorResult._fetchmany_impl% s@  ! !%OO99$++d:KLDMw&D&11rD)FNF) rpr-rfzBCallable[[Optional[int]], Iterator[Sequence[_InterimRowType[_R]]]]rjrrNrrirrr\r`r>r^) rrrrrrrrr __classcell__rs@rBrdrds *).%)"'3'3 3 "& 3#3 3"  & %)2!2 (22rDrdcFeZdZUdZdZded< dfd Zdd dZxZS) rzA :class:`_engine.Result` that is merged from any number of :class:`_engine.Result` objects. Returned by the :meth:`_engine.Result.merge` method. .. versionadded:: 1.4 Frrowcountcj||_t| |tjj d|D|dj |_|dj|_|dj|_|jj|Dcgc]}|jc}|_ ycc}w)Nc3<K|]}|jywr>)r)r/rs rBr0z(MergedResult.__init__..@ s**+##%*sr) _resultsrorr]rgrhrr5rrn merge_with)rArpresultsrwrs rBrzMergedResult.__init__: s     OO ) )*/6*  %,AJ$C$C!!!*//)0 (K(K%64++66%, -amm -  -sB0c b|jD]}|jdd|i||rd|_yy)NrTr.)rxrr)rArrSrws rBrzMergedResult._soft_closeO s: +A AMM *t *r * + DK rD)rpr-rzzSequence[Result[_TP]]r\r`) rrrrrrrrrqrrs@rBrr- s4F - 8M *rDrr>)rr7rrr|z#Callable[[Iterable[Any]], Row[Any]])r|zIteratorResult[Any])Xr __future__renumrrr]rftypingrrrrr r r r r rrrrrrrrrrrrrrsql.baserrrr r! util._has_cyr" util.typingr#r$_py_rowr%"sqlalchemy.cyextension.resultproxy sql.elementsr& sql.type_apir'r_KeyTyperrrr5_RowData _RawRowTyper(r*r+_InterimRowType_InterimSupportsScalarsRowType_ProcessorsTyper_UniqueFilterTyperer-KeysViewr?rrrrrrirlrr TypingOnlyrrrrHrbrdrr.rDrBrs,"  ""(4*! 3M 03 .. /hm$ h./  S:s* +CHo ; T" T e5c?+K( "'s3x}!58$?@AXc]OXc]:;cUCZ(s3x2C)DDEu$u$p)$)DK>K^37 "/(T ..Z!& Z!z##4g >Ys3x0g >T]<>"%]<@@ <#@ F`,r"DOO`FK I|J7K \M73<M`P>VC[P>f>62N3/62r&>#&&rD