class documentation

class Row(BaseRow, collections_abc.Sequence):

Known subclasses: sqlalchemy.engine.row.LegacyRow

View In Hierarchy

Represent a single result row.

The .Row object represents a row of a database result. It is typically associated in the 1.x series of SQLAlchemy with the _engine.CursorResult object, however is also used by the ORM for tuple-like results as of SQLAlchemy 1.4.

The .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 .Row._mapping attribute.

See Also

:ref:`coretutorial_selecting` - includes examples of selecting rows from SELECT statements.

.LegacyRow - Compatibility interface introduced in SQLAlchemy 1.4.

Changed in version 1.4: Renamed RowProxy to .Row. .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 .Row._mapping attribute, but will remain available in SQLAlchemy 1.x series via the .LegacyRow class that is used by _engine.LegacyCursorResult. See :ref:`change_4710_core` for background on this change.
Method __contains__ Undocumented
Method __delattr__ Undocumented
Method __eq__ Undocumented
Method __ge__ Undocumented
Method __getstate__ Undocumented
Method __gt__ Undocumented
Method __le__ Undocumented
Method __lt__ Undocumented
Method __ne__ Undocumented
Method __repr__ Undocumented
Method __setattr__ Undocumented
Method __setstate__ Undocumented
Method ​_asdict Return a new dict which maps field names to their corresponding values.
Method ​_op Undocumented
Method ​_replace Undocumented
Method ​_special​_name​_accessor Handle ambiguous names such as "count" and "index"
Method keys Return the list of keys as strings represented by this .Row.
Class Variable __slots__ Undocumented
Class Variable count Undocumented
Class Variable index Undocumented
Property ​_field​_defaults Undocumented
Property ​_fields Return a tuple of string keys as represented by this .Row.
Property ​_mapping Return a .RowMapping for this .Row.

Inherited from BaseRow:

Method __getattr__ Undocumented
Method __hash__ Undocumented
Method __init__ Row objects are constructed by CursorResult objects.
Method __iter__ Undocumented
Method __len__ Undocumented
Method __reduce__ Undocumented
Method ​_filter​_on​_values Undocumented
Method ​_get​_by​_int​_impl Undocumented
Method ​_get​_by​_key​_impl Undocumented
Method ​_get​_by​_key​_impl​_mapping Undocumented
Method ​_values​_impl Undocumented
def __contains__(self, key):

Undocumented

def __delattr__(self, name):

Undocumented

def __eq__(self, other):

Undocumented

def __ge__(self, other):

Undocumented

def __getstate__(self):

Undocumented

def __gt__(self, other):

Undocumented

def __le__(self, other):

Undocumented

def __lt__(self, other):

Undocumented

def __ne__(self, other):

Undocumented

def __repr__(self):

Undocumented

def __setattr__(self, name, value):

Undocumented

def __setstate__(self, state):

Undocumented

def _asdict(self):

Return 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 .Row._mapping attribute.

New in version 1.4.

See Also

.Row._mapping

def _op(self, other, op):

Undocumented

def _replace(self):

Undocumented

def _special_name_accessor(name):
Handle ambiguous names such as "count" and "index"
@util.deprecated_20(':meth:`.Row.keys`', alternative='Use the namedtuple standard accessor :attr:`.Row._fields`, or for full mapping behavior use row._mapping.keys() ')
def keys(self):

Return the list of keys as strings represented by this .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 method is analogous to the Python dictionary .keys() method, except that it returns a list, not an iterator.

See Also

.Row._fields

.Row._mapping

__slots__: tuple =
count =

Undocumented

index =

Undocumented

@property
_field_defaults =

Undocumented

@property
_fields =

Return a tuple of string keys as represented by this .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.

New in version 1.4.

See Also

.Row._mapping

@property
_mapping =

Return a .RowMapping for this .Row.

This object provides a consistent Python mapping (i.e. dictionary) interface for the data contained within the row. The .Row by itself behaves like a named tuple, however in the 1.4 series of SQLAlchemy, the .LegacyRow class is still used by Core which continues to have mapping-like behaviors against the row object itself.

See Also

.Row._fields

New in version 1.4.