MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / Row

Class Row

lib/sqlalchemy/engine/row.py:50–280  ·  view source on GitHub ↗

Represent 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.

Source from the content-addressed store, hash-verified

48
49
50class Row(BaseRow, Sequence[Any], Generic[_TP]):
51 """Represent a single result row.
52
53 The :class:`.Row` object represents a row of a database result. It is
54 typically associated in the 1.x series of SQLAlchemy with the
55 :class:`_engine.CursorResult` object, however is also used by the ORM for
56 tuple-like results as of SQLAlchemy 1.4.
57
58 The :class:`.Row` object seeks to act as much like a Python named
59 tuple as possible. For mapping (i.e. dictionary) behavior on a row,
60 such as testing for containment of keys, refer to the :attr:`.Row._mapping`
61 attribute.
62
63 .. seealso::
64
65 :ref:`tutorial_selecting_data` - includes examples of selecting
66 rows from SELECT statements.
67
68 .. versionchanged:: 1.4
69
70 Renamed ``RowProxy`` to :class:`.Row`. :class:`.Row` is no longer a
71 "proxy" object in that it contains the final form of data within it,
72 and now acts mostly like a named tuple. Mapping-like functionality is
73 moved to the :attr:`.Row._mapping` attribute. See
74 :ref:`change_4710_core` for background on this change.
75
76 """
77
78 __slots__ = ()
79
80 def __setattr__(self, name: str, value: Any) -> NoReturn:
81 raise AttributeError("can't set attribute")
82
83 def __delattr__(self, name: str) -> NoReturn:
84 raise AttributeError("can't delete attribute")
85
86 def _tuple(self) -> _TP:
87 """Return a 'tuple' form of this :class:`.Row`.
88
89 At runtime, this method returns "self"; the :class:`.Row` object is
90 already a named tuple. However, at the typing level, if this
91 :class:`.Row` is typed, the "tuple" return type will be a :pep:`484`
92 ``Tuple`` datatype that contains typing information about individual
93 elements, supporting typed unpacking and attribute access.
94
95 .. versionadded:: 2.0.19 - The :meth:`.Row._tuple` method supersedes
96 the previous :meth:`.Row.tuple` method, which is now underscored
97 to avoid name conflicts with column names in the same way as other
98 named-tuple methods on :class:`.Row`.
99
100 .. seealso::
101
102 :attr:`.Row._t` - shorthand attribute notation
103
104 :meth:`.Result.tuples`
105
106
107 """

Callers 6

test_nontuple_rowMethod · 0.90
test_row_is_sequenceMethod · 0.90
test_row_is_hashableMethod · 0.90
_filter_on_valuesMethod · 0.70

Calls

no outgoing calls

Tested by 5

test_nontuple_rowMethod · 0.72
test_row_is_sequenceMethod · 0.72
test_row_is_hashableMethod · 0.72