zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
U
¸ý°dA*ã@sdZddlmZddlmZddlmZddlZddlZddlm    Z    ddlm
Z
ddlm Z ddlm Z dd    lm Z dd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZesesddlmZn ddlmZerTddl m!Z!ddl m"Z"ddl m#Z#ede    dZ$edee    dfdZ%Gd d!„d!eee    e e%ƒZ&eZ'e&Z(Gd"d#„d#eƒZ)Gd$d%„d%e)ej*d&ej+e    ƒZ,Gd'd(„d(e)ej-d&e    fƒZ.Gd)d*„d*eejd&e    fƒZ/dS)+z.Define row constructs including :class:`.Row`.é)Ú annotations)ÚABCN)ÚAny)ÚCallable)ÚDict)ÚGeneric)ÚIterator)ÚList)ÚMapping)ÚNoReturn)ÚOptional)Úoverload)ÚSequence)ÚTuple)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Úutil)ÚHAS_CYEXTENSIONé)ÚBaseRow)Ú_KeyType)Ú_ProcessorsType)Ú    RMKeyViewÚ_T)ÚboundÚ_TP.c@sŽeZdZdZdZddddœdd„Zddd    œd
d „Zd d œdd„Zed d œdd„ƒZ    edd œdd„ƒZ
dddœdd„Z e s˜ddd    œdd„Z e dƒZe dƒZdddœd d!„Zdd"dd#œd$d%„ZejZe rüed&dd'œd(d)„ƒZed*d+d'œd,d)„ƒZd-dd'œd.d)„Zddd/œd0d1„Zddd/œd2d3„Zddd/œd4d5„Zddd/œd6d7„Zddd/œd8d9„Zddd/œd:d;„Zdd œd<d=„Zed>d œd?d@„ƒZdAd œdBdC„ZdDS)EÚ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.
 
    ©Ústrrr )ÚnameÚvalueÚreturncCs tdƒ‚dS)Nzcan't set attribute©ÚAttributeError)Úselfr!r"rrúLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/engine/row.pyÚ __setattr__OszRow.__setattr__)r!r#cCs tdƒ‚dS)Nzcan't delete attributer$)r&r!rrr'Ú __delattr__RszRow.__delattr__r©r#cCs|S)aþReturn a 'tuple' form of this :class:`.Row`.
 
        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
 
        .. seealso::
 
            :meth:`.Result.tuples`
 
        r©r&rrr'ÚtupleUsz    Row.tuplecCs|S)z~a synonym for :attr:`.Row.tuple`
 
        .. versionadded:: 2.0
 
        .. seealso::
 
            :meth:`.Result.t`
 
        rr+rrr'Útgs zRow.tÚ
RowMappingcCst|jd|j|jƒ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)r.Ú_parentÚ _key_to_indexÚ_datar+rrr'Ú_mappingtsz Row._mappingzOptional[_ProcessorsType]zRow[Any])Ú    processorr#cCst|j||j|jƒS©N)rr/r0r1)r&r3rrr'Ú_filter_on_values…szRow._filter_on_valuescstdddœ‡fdd„ ƒ}|S)z3Handle ambiguous names such as "count" and "index" rr)r&r#cs6ˆj ˆ¡rˆ ˆ¡Sddddœ‡‡fdd„ }|SdS)Nr)ÚargÚkwr#csttjˆƒˆf|ž|ŽSr4)ÚgetattrÚcollections_abcr)r6r7)r!r&rr'Úmeth•s
ÿÿÿz4Row._special_name_accessor.<locals>.go.<locals>.meth)r/Ú_has_keyÚ __getattr__)r&r:©r!r+r'Úgos 
z&Row._special_name_accessor.<locals>.go)Úproperty)r!r>rr=r'Ú_special_name_accessorŒs zRow._special_name_accessorÚcountÚindexÚbool©Úkeyr#cCs
||jkSr4)r1©r&rErrr'Ú __contains__¡szRow.__contains__zCallable[[Any, Any], bool])ÚotherÚopr#cCs*t|tƒr|| ¡| ¡ƒS|| ¡|ƒSr4)Ú
isinstancerZ_to_tuple_instance)r&rHrIrrr'Ú_op¤sÿ ýzRow._opÚint)rBr#cCsdSr4r©r&rBrrr'Ú __getitem__¯szRow.__getitem__Úsliceú Sequence[Any]cCsdSr4rrMrrr'rN³szUnion[int, slice]cCsdSr4rrMrrr'rN·s©rHr#cCs| |tj¡Sr4)rKÚoperatorÚlt©r&rHrrr'Ú__lt__ºsz
Row.__lt__cCs| |tj¡Sr4)rKrRÚlerTrrr'Ú__le__½sz
Row.__le__cCs| |tj¡Sr4)rKrRÚgerTrrr'Ú__ge__Àsz
Row.__ge__cCs| |tj¡Sr4)rKrRÚgtrTrrr'Ú__gt__Ãsz
Row.__gt__cCs| |tj¡Sr4)rKrRÚeqrTrrr'Ú__eq__Æsz
Row.__eq__cCs| |tj¡Sr4)rKrRÚnerTrrr'Ú__ne__Ész
Row.__ne__cCstt |¡ƒSr4)ÚreprÚsql_utilZ    _repr_rowr+rrr'Ú__repr__Ìsz Row.__repr__zTuple[str, ...]cCstdd„|jjDƒƒS)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`
 
        cSsg|]}|dk    r|‘qSr4r©Ú.0Úkrrr'Ú
<listcomp>âszRow._fields.<locals>.<listcomp>)r,r/Úkeysr+rrr'Ú_fieldsÏsz Row._fieldszDict[str, Any]cCs
t|jƒ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`
 
        )Údictr2r+rrr'Ú_asdictäsz Row._asdictN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú    __slots__r(r)r,r?r-r2r5rr@rArBrGrKrÚ__hash__r rNrUrWrYr[r]r_rbrhrjrrrr'r1sB rc@sŒeZdZUdZded<ded<dddœdd„Zd    d
œd d „Zd d
œdd„Zdd
œdd„Zdddœdd„Z    dddœdd„Z
dddœdd„Z dS)Ú ROMappingViewrrPÚ_itemszMapping['_KeyType', Any]r2)ÚmappingÚitemscCs||_||_dSr4)r2rr)r&rsrtrrr'Ú__init__szROMappingView.__init__rLr*cCs
t|jƒSr4)Úlenrrr+rrr'Ú__len__szROMappingView.__len__r cCs
d |¡S)Nz&{0.__class__.__name__}({0._mapping!r}))Úformatr+rrr'rb    szROMappingView.__repr__z Iterator[Any]cCs
t|jƒSr4)Úiterrrr+rrr'Ú__iter__ szROMappingView.__iter__rrC)Úitemr#cCs
||jkSr4©rr)r&r{rrr'rGszROMappingView.__contains__rQcCst|ƒt|ƒkSr4©ÚlistrTrrr'r]szROMappingView.__eq__cCst|ƒt|ƒkSr4r}rTrrr'r_szROMappingView.__ne__N) rkrlrmroÚ__annotations__rurwrbrzrGr]r_rrrr'rqús
rqc@seZdZdZdS)ÚROMappingKeysValuesViewr|N©rkrlrmrorrrr'r€sr€rc@seZdZdZdS)ÚROMappingItemsViewr|Nrrrrr'r‚sr‚c@s¢eZdZdZdZer&dddœdd„ZnejZdd    œd
d „Z    d d    œd d„Z
dd    œdd„Z dddœdd„Z dd    œdd„Z dd    œdd„Zdd    œdd„Zdd    œd d!„Zd"S)#r.aé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.
 
    rrrrDcCsdSr4rrFrrr'rNBszRowMapping.__getitem__z    List[Any]r*cCs
t|jƒSr4)r~r1r+rrr'Ú _values_implHszRowMapping._values_implz Iterator[str]cCsdd„|jjDƒS)Ncss|]}|dk    r|VqdSr4rrcrrr'Ú    <genexpr>Lsz&RowMapping.__iter__.<locals>.<genexpr>©r/rgr+rrr'rzKszRowMapping.__iter__rLcCs
t|jƒSr4)rvr1r+rrr'rwNszRowMapping.__len__ÚobjectrCcCs |j |¡Sr4)r/r;rFrrr'rGQszRowMapping.__contains__r cCs tt|ƒƒSr4)r`rir+rrr'rbTszRowMapping.__repr__r‚cstˆ‡fdd„ˆ ¡DƒƒS)zeReturn a view of key/value tuples for the elements in the
        underlying :class:`.Row`.
 
        csg|]}|ˆ|f‘qSrr)rdrEr+rr'rf]sz$RowMapping.items.<locals>.<listcomp>)r‚rgr+rr+r'rtWsÿzRowMapping.itemsrcCs|jjS)znReturn a view of 'keys' for string column names represented
        by the underlying :class:`.Row`.
 
        r…r+rrr'rg`szRowMapping.keysr€cCst|| ¡ƒS)zeReturn a view of values for the values represented in the
        underlying :class:`.Row`.
 
        )r€rƒr+rrr'ÚvalueshszRowMapping.valuesN)rkrlrmrnrorrNrZ_get_by_key_impl_mappingrƒrzrwrGrbrtrgr‡rrrr'r.#s    r.)0rnÚ
__future__rÚabcrÚcollections.abcr9rRÚtypingrrrrrr    r
r r r rrrrrZsqlrraZ util._has_cyrZ_py_rowrZ"sqlalchemy.cyextension.resultproxyÚresultrrrrrrZ BaseRowProxyZRowProxyrqÚKeysViewÚ
ValuesViewr€Ú    ItemsViewr‚r.rrrr'Ú<module>sV                          F
ÿ