Files
aitsc/.venv/Lib/site-packages/sqlalchemy/engine/__pycache__/row.cpython-312.pyc

181 lines
17 KiB
Plaintext
Raw Normal View History

2025-02-23 09:07:52 +08:00
<EFBFBD>
2025-08-16 19:28:45 +08:00
<00><18>h<EFBFBD>0<00><01><><00>dZddlmZddlmZddlmZddlZddlZddlm Z ddlm
2025-02-23 09:07:52 +08:00
Z
ddlm Z ddlm Z dd lm Z dd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZesesddlmZnddl mZerddl!m"Z"ddl!m#Z#ddl!m$Z$ede <09><1E>Z%edee d f<00><1E>Z&Gd!<21>d"eee e e&<00>Z'eZ(e'Z)Gd#<23>d$e<04>Z*Gd%<25>d&e*ejVd'ejXe <00>Z-Gd(<28>d)e*ej\d'e f<00>Z/Gd*<2A>d+eejd'e f<00>Z0y),z.Define row constructs including :class:`.Row`.<2E>)<01> annotations)<01>ABCN)<01>Any)<01>Callable)<01>Dict)<01>Generic)<01>Iterator)<01>List)<01>Mapping)<01>NoReturn)<01>Optional)<01>overload)<01>Sequence)<01>Tuple)<01> TYPE_CHECKING)<01>TypeVar)<01>Union<6F>)<01>util)<01>
deprecated)<01>HAS_CYEXTENSION<4F>)<01>BaseRow)<01>_KeyType)<01>_ProcessorsType)<01> RMKeyView<65>_T)<01>bound<6E>_TP.c<01><><00>eZdZdZdZd d<03>Zd!d<04>Zd"d<05>Zedd<07>d"d<08><04>Z e
d"d <09><04>Z e
edd
<EFBFBD>d"d <0B><04><00>Z e
d#d <0C><04>Z d$d <0A>Zesd%d<0E>Zed<0F>Zed<10>Zd&d<11>Zd'd<12>Zej,Zered(d<13><04>Zed)d<14><04>Zd*d<15>Zd+d<16>Zd+d<17>Zd+d<18>Zd+d<19>Zd+d<1A>Zd+d<1B>Zd,d<1C>Ze
d-d<1D><04>Z d.d<1E>Z!y)/<2F>RowaRepresent a single result row.
The :class:`.Row` object represents a row of a database result. It is
typically associated in the 1.x series of SQLAlchemy with the
:class:`_engine.CursorResult` object, however is also used by the ORM for
tuple-like results as of SQLAlchemy 1.4.
The :class:`.Row` object seeks to act as much like a Python named
tuple as possible. For mapping (i.e. dictionary) behavior on a row,
such as testing for containment of keys, refer to the :attr:`.Row._mapping`
attribute.
.. seealso::
:ref:`tutorial_selecting_data` - includes examples of selecting
rows from SELECT statements.
.. versionchanged:: 1.4
Renamed ``RowProxy`` to :class:`.Row`. :class:`.Row` is no longer a
"proxy" object in that it contains the final form of data within it,
and now acts mostly like a named tuple. Mapping-like functionality is
moved to the :attr:`.Row._mapping` attribute. See
:ref:`change_4710_core` for background on this change.
2025-08-16 19:28:45 +08:00
<20>c<01><00>td<01><00>)Nzcan't set attribute<74><01>AttributeError)<03>self<6C>name<6D>values <20>9D:\aitsc\.venv\Lib\site-packages\sqlalchemy\engine\row.py<70> __setattr__zRow.__setattr__Ps<00><00><1C>2<>3<>3<>c<01><00>td<01><00>)Nzcan't delete attributer$)r&r's r)<00> __delattr__zRow.__delattr__Ss<00><00><1C>5<>6<>6r+c<01><00>|S)a5Return a 'tuple' form of this :class:`.Row`.
2025-02-23 09:07:52 +08:00
At runtime, this method returns "self"; the :class:`.Row` object is
already a named tuple. However, at the typing level, if this
:class:`.Row` is typed, the "tuple" return type will be a :pep:`484`
``Tuple`` datatype that contains typing information about individual
elements, supporting typed unpacking and attribute access.
.. versionadded:: 2.0.19 - The :meth:`.Row._tuple` method supersedes
the previous :meth:`.Row.tuple` method, which is now underscored
to avoid name conflicts with column names in the same way as other
named-tuple methods on :class:`.Row`.
.. seealso::
:attr:`.Row._t` - shorthand attribute notation
:meth:`.Result.tuples`
r"<00>r&s r)<00>_tuplez
Row._tupleVs <00><00>,<14> r+z2.0.19z<EFBFBD>The :meth:`.Row.tuple` method is deprecated in favor of :meth:`.Row._tuple`; all :class:`.Row` methods and library-level attributes are intended to be underscored to avoid name conflicts. Please use :meth:`Row._tuple`.c<01>"<00>|j<00>S)zUReturn a 'tuple' form of this :class:`.Row`.
.. versionadded:: 2.0
)r0r/s r)<00>tuplez Row.tuplens<00><00><14>{<7B>{<7B>}<7D>r+c<01><00>|S)awA synonym for :meth:`.Row._tuple`.
.. versionadded:: 2.0.19 - The :attr:`.Row._t` attribute supersedes
the previous :attr:`.Row.t` attribute, which is now underscored
to avoid name conflicts with column names in the same way as other
named-tuple methods on :class:`.Row`.
.. seealso::
:attr:`.Result.t`
r"r/s r)<00>_tzRow._t}s <00><00><14> r+z<>The :attr:`.Row.t` attribute is deprecated in favor of :attr:`.Row._t`; all :class:`.Row` methods and library-level attributes are intended to be underscored to avoid name conflicts. Please use :attr:`Row._t`.c<01><00>|jS)zKA synonym for :meth:`.Row._tuple`.
.. versionadded:: 2.0
)r4r/s r)<00>tzRow.t<>s <00><00><14>w<EFBFBD>w<EFBFBD>r+c<01>Z<00>t|jd|j|j<00>S)a]Return a :class:`.RowMapping` for this :class:`.Row`.
This object provides a consistent Python mapping (i.e. dictionary)
interface for the data contained within the row. The :class:`.Row`
by itself behaves like a named tuple.
.. seealso::
:attr:`.Row._fields`
.. versionadded:: 1.4
N)<04>
RowMapping<EFBFBD>_parent<6E> _key_to_index<65>_datar/s r)<00>_mappingz Row._mapping<6E>s#<00><00><1A>$<24>,<2C>,<2C><04>d<EFBFBD>.@<40>.@<40>$<24>*<2A>*<2A>M<>Mr+c<01>Z<00>t|j||j|j<00>S<00>N)r!r9r:r;)r&<00> processors r)<00>_filter_on_valueszRow._filter_on_values<65>s#<00><00><13>4<EFBFBD><<3C><<3C><19>D<EFBFBD>,><3E>,><3E><04>
<EFBFBD>
<EFBFBD>K<>Kr+c<01>&<00><00>td<02>fd<01> <0C>}|S)z3Handle ambiguous names such as "count" and "index" c<01>p<00><01><00><00>jj<00><02>r<11>j<00><02>Sd<02><02>fd<01> }|S)Nc<01>L<00><02>ttj<00><02><00>g|<00><01>i|<01><01>Sr>)<03>getattr<74>collections_abcr)<04>arg<72>kwr'r&s <20><>r)<00>methz4Row._special_name_accessor.<locals>.go.<locals>.meth<74>s2<00><><00>F<>w<EFBFBD><EFBFBD>'?<3F>'?<3F><14>F<> <20> <1A>#&<26> <1A>*,<2C> <1A>r+)rFrrGr<00>returnr)r9<00>_has_key<65> __getattr__)r&rHr's` <20>r)<00>goz&Row._special_name_accessor.<locals>.go<67>s2<00><><00><17><<3C><<3C>(<28>(<28><14>.<2E><1F>+<2B>+<2B>D<EFBFBD>1<>1<><1A>
 <20>Kr+)r&r!rIr)<01>property)r'rLs` r)<00>_special_name_accessorzRow._special_name_accessor<6F>s<00><><00><16>
<20><16>
<20><16>Ir+<00>count<6E>indexc<01><00>||jvSr>)r;<00>r&<00>keys r)<00> __contains__zRow.__contains__<5F>s<00><00><12>d<EFBFBD>j<EFBFBD>j<EFBFBD> <20> r+c<01><><00>t|t<00>r%||j<00>|j<00><00>S||j<00>|<01>Sr>)<03>
isinstancer!<00>_to_tuple_instance)r&<00>other<65>ops r)<00>_opzRow._op<6F>sK<00><00><1A>%<25><13>%<25> <0F>t<EFBFBD>&<26>&<26>(<28>%<25>*B<>*B<>*D<> E<>
<EFBFBD><14>D<EFBFBD>+<2B>+<2B>-<2D>u<EFBFBD>5<>
r+c<01><00>yr>r"<00>r&rPs r)<00> __getitem__zRow.__getitem__<5F>s<00><00>25r+c<01><00>yr>r"r\s r)r]zRow.__getitem__<5F>s<00><00>>Ar+c<01><00>yr>r"r\s r)r]zRow.__getitem__<5F>s<00><00>r+c<01>B<00>|j|tj<00>Sr>)rZ<00>operator<6F>lt<6C>r&rXs r)<00>__lt__z
Row.__lt__<5F><00><00><00><13>x<EFBFBD>x<EFBFBD><05>x<EFBFBD>{<7B>{<7B>+<2B>+r+c<01>B<00>|j|tj<00>Sr>)rZra<00>lercs r)<00>__le__z
Row.__le__<5F>rer+c<01>B<00>|j|tj<00>Sr>)rZra<00>gercs r)<00>__ge__z
Row.__ge__<5F>rer+c<01>B<00>|j|tj<00>Sr>)rZra<00>gtrcs r)<00>__gt__z
Row.__gt__<5F>rer+c<01>B<00>|j|tj<00>Sr>)rZra<00>eqrcs r)<00>__eq__z
Row.__eq__<5F>rer+c<01>B<00>|j|tj<00>Sr>)rZra<00>nercs r)<00>__ne__z
Row.__ne__<5F>rer+c<01>><00>ttj|<00><00>Sr>)<03>repr<70>sql_util<69> _repr_rowr/s r)<00>__repr__z Row.__repr__<5F>s<00><00><13>H<EFBFBD>&<26>&<26>t<EFBFBD>,<2C>-<2D>-r+c<01>l<00>t|jjD<00>cgc]}|<01><01>|<01><02> c}<01>Scc}w)a<>Return a tuple of string keys as represented by this
:class:`.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.
This attribute is analogous to the Python named tuple ``._fields``
attribute.
.. versionadded:: 1.4
.. seealso::
:attr:`.Row._mapping`
)r2r9<00>keys)r&<00>ks r)<00>_fieldsz Row._fields<64>s1<00><00>&<15><14><1C><1C>!2<>!2<>D<>!2<>A<EFBFBD>a<EFBFBD>m<EFBFBD>a<EFBFBD>!2<>D<>E<>E<><45>Ds<00>1<08>1c<01>,<00>t|j<00>S)amReturn a new dict which maps field names to their corresponding
values.
This method is analogous to the Python named tuple ``._asdict()``
method, and works by applying the ``dict()`` constructor to the
:attr:`.Row._mapping` attribute.
.. versionadded:: 1.4
.. seealso::
:attr:`.Row._mapping`
)<02>dictr<r/s r)<00>_asdictz Row._asdict s<00><00><14>D<EFBFBD>M<EFBFBD>M<EFBFBD>"<22>"r+N)r'<00>strr(rrIr )r'r<>rIr )rIr)rIr8)r?zOptional[_ProcessorsType]rIzRow[Any])r'r<>rIr)rSrrI<00>bool)rXrrYzCallable[[Any, Any], bool]rIr<>)rP<00>intrIr)rP<00>slicerI<00> Sequence[Any])rPzUnion[int, slice]rIr<00>rXrrIr<><00>rIr<>)rIzTuple[str, ...])rIzDict[str, Any])"<22>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F> __slots__r*r-r0rr2rMr4r6r<r@rrNrOrPrTrZr<00>__hash__rr]rdrhrkrnrqrtryr}r<>r"r+r)r!r!2sA<00><00><08>6<13>I<EFBFBD>4<>7<><14>0<10><10> C<01><06><1D><06><1D><0E> <14><0E> <14><0E><0F><10> ?<3F><06><17><06><0E><17><0E>N<01><0E>N<01> L<01>2<>L<01> <11>L<01>
<19> <16>$'<27>w<EFBFBD>/<2F><05>&<26>w<EFBFBD>/<2F><05>!<21>
<EFBFBD><17><1F><1F>H<EFBFBD><14> <11>5<>
<12>5<> <11>A<>
<12>A<>C<>,<2C>,<2C>,<2C>,<2C>,<2C>,<2C>.<2E><0E>F<01><0E>F<01>(#r+r!c<01>f<00>eZdZUdZded<ded< dd<06>Zdd<07>Zdd<08>Zdd <09>Zdd
<EFBFBD>Z dd <0B>Z
dd <0C>Z y )<14> ROMappingViewr"r<><00>_items<6D>Mapping['_KeyType', Any]r<c<01> <00>||_||_yr>)r<r<>)r&<00>mapping<6E>itemss r)<00>__init__zROMappingView.__init__%s<00><00> <20><04> <0A><1B><04> r+c<01>,<00>t|j<00>Sr>)<02>lenr<6E>r/s r)<00>__len__zROMappingView.__len__+s<00><00><12>4<EFBFBD>;<3B>;<3B><1F>r+c<01>$<00>dj|<00>S)Nz&{0.__class__.__name__}({0._mapping!r}))<01>formatr/s r)ryzROMappingView.__repr__.s<00><00>7<>><3E>><3E>t<EFBFBD>D<>Dr+c<01>,<00>t|j<00>Sr>)<02>iterr<72>r/s r)<00>__iter__zROMappingView.__iter__1s<00><00><13>D<EFBFBD>K<EFBFBD>K<EFBFBD> <20> r+c<01><00>||jvSr><00>r<>)r&<00>items r)rTzROMappingView.__contains__4s<00><00><13>t<EFBFBD>{<7B>{<7B>"<22>"r+c<01>0<00>t|<01>t|<00>k(Sr><00><01>listrcs r)rqzROMappingView.__eq__7<00><00><00><13>E<EFBFBD>{<7B>d<EFBFBD>4<EFBFBD>j<EFBFBD>(<28>(r+c<01>0<00>t|<01>t|<00>k7Sr>r<>rcs r)rtzROMappingView.__ne__:r<>r+N)r<>r<>r<>r<><00>rIr<>r<>)rIz Iterator[Any])r<>rrIr<>r<>) r<>r<>r<>r<><00>__annotations__r<5F>r<>ryr<>rTrqrtr"r+r)r<>r<>sG<00><00><12>I<EFBFBD> <19><19>&<26>&<26><1C>/<2F><1C>8E<38><1C>  <20>E<01>!<21>#<23>)<29>)r+r<>c<01><00>eZdZdZy)<03>ROMappingKeysValuesViewr<77>N<>r<>r<>r<>r<>r"r+r)r<>r<>>s <00><00><1C>Ir+r<>rc<01><00>eZdZdZy)<03>ROMappingItemsViewr<77>Nr<4E>r"r+r)r<>r<>Ds<00><00><1B>Ir+r<>c<01>z<00>eZdZdZdZerd d<03>Zn ejZdd<04>Z dd<05>Z
dd<06>Z dd<07>Z dd<08>Z dd <09>Zdd
<EFBFBD>Zdd <0B>Zy )r8a<>A ``Mapping`` that maps column names and objects to :class:`.Row`
values.
The :class:`.RowMapping` is available from a :class:`.Row` via the
:attr:`.Row._mapping` attribute, as well as from the iterable interface
provided by the :class:`.MappingResult` object returned by the
:meth:`_engine.Result.mappings` method.
:class:`.RowMapping` supplies Python mapping (i.e. dictionary) access to
the contents of the row. This includes support for testing of
containment of specific keys (string column names or objects), as well
as iteration of keys, values, and items::
for row in result:
if "a" in row._mapping:
print("Column 'a': %s" % row._mapping["a"])
print("Column b: %s" % row._mapping[table.c.b])
.. versionadded:: 1.4 The :class:`.RowMapping` object replaces the
mapping-like access previously provided by a database result row,
which now seeks to behave mostly like a named tuple.
r"c<01><00>yr>r"rRs r)r]zRowMapping.__getitem__fs<00><00>Sr+c<01>,<00>t|j<00>Sr>)r<>r;r/s r)<00> _values_implzRowMapping._values_implks<00><00><13>D<EFBFBD>J<EFBFBD>J<EFBFBD><1F>r+c<01><<00>d<01>|jjD<00>S)Nc3<01>&K<00>|] }|<01><01>|<01><01><00> y<00>wr>r")<02>.0r|s r)<00> <genexpr>z&RowMapping.__iter__.<locals>.<genexpr>os<00><00><><00>><3E>,<2C>a<EFBFBD><01> <0A><01>,<2C>s<00><01><01>r9r{r/s r)r<>zRowMapping.__iter__ns<00><00>><3E>4<EFBFBD><<3C><<3C>,<2C>,<2C>><3E>>r+c<01>,<00>t|j<00>Sr>)r<>r;r/s r)r<>zRowMapping.__len__qs<00><00><12>4<EFBFBD>:<3A>:<3A><EFBFBD>r+c<01>8<00>|jj|<01>Sr>)r9rJrRs r)rTzRowMapping.__contains__ts<00><00><13>|<7C>|<7C>$<24>$<24>S<EFBFBD>)<29>)r+c<01>*<00>tt|<00><00>Sr>)rvrr/s r)ryzRowMapping.__repr__ws<00><00><13>D<EFBFBD><14>J<EFBFBD><1F>r+c <01>f<00>t||j<00>D<00>cgc] }|||f<02><02> c}<01>Scc}w)zeReturn a view of key/value tuples for the elements in the
underlying :class:`.Row`.
)r<>r{rRs r)r<>zRowMapping.itemszs7<00><00>
"<22> <10>t<EFBFBD>y<EFBFBD>y<EFBFBD>{<7B>;<3B>{<7B><03>C<EFBFBD><14>c<EFBFBD><19>#<23>{<7B>;<3B>
<EFBFBD>
<EFBFBD><EFBFBD>;s<00>.
c<01>.<00>|jjS)znReturn a view of 'keys' for string column names represented
by the underlying :class:`.Row`.
r<>r/s r)r{zRowMapping.keys<79>s<00><00> <14>|<7C>|<7C> <20> <20> r+c<01>6<00>t||j<00><00>S)zeReturn a view of values for the values represented in the
underlying :class:`.Row`.
)r<>r<>r/s r)<00>valueszRowMapping.values<65>s<00><00>
'<27>t<EFBFBD>T<EFBFBD>-><3E>-><3E>-@<40>A<>Ar+N)rSrrIr)rIz List[Any])rIz Iterator[str]r<>)rS<00>objectrIr<>r<>)rIr<>)rIr)rIr<>)r<>r<>r<>r<>r<>rr]r<00>_get_by_key_impl_mappingr<67>r<>r<>rTryr<>r{r<>r"r+r)r8r8HsJ<00><00><08>2<13>I<EFBFBD><14>8<><1E>6<>6<> <0B> <20>?<3F><1F>*<2A> <20>
<EFBFBD>!<21>Br+r8)1r<31><00>
__future__r<00>abcr<00>collections.abcrEra<00>typingrrrrr r
r r r rrrrrr<00>sqlrrwr<00> util._has_cyr<00>_py_rowr<00>"sqlalchemy.cyextension.resultproxy<78>resultrrrrrr!<00> BaseRowProxy<78>RowProxyr<79><00>KeysView<65>
ValuesViewr<EFBFBD><00> ItemsViewr<77>r8r"r+r)<00><module>r<>s<00><01>5<>"<22><13>)<29><0F> <0A><16><1B><17><1A><1B><17><1A><1B><1B><1B><1B><18> <20><1A><18>"<22><1D>*<2A><10><0F>+<2B>E<><10> <20>'<27>!<21> <0C>T<EFBFBD><13><1D><02> <0A>e<EFBFBD>5<EFBFBD><13>c<EFBFBD><18>?<3F>+<2B><03>f#<23>'<27>8<EFBFBD>C<EFBFBD>=<3D>'<27>#<23>,<2C>f#<23>R<17> <0C> <0E><08>)<29>C<EFBFBD>)<29>><1C><11>6<EFBFBD>?<3F>?<3F>:<3A>.<2E><06>0A<30>0A<30>#<23>0F<30><1C> <1C><1D><06>(8<>(8<><1A>S<EFBFBD><1F>(I<><1C>HB<01><17>&<26>.<2E>.<2E><1A>S<EFBFBD><1F>9<>HBr+