class documentation

class ScalarResult(FilterResult[_R]): (source)

View In Hierarchy

A wrapper for a :class:`_engine.Result` that returns scalar values rather than :class:`_row.Row` values. The :class:`_engine.ScalarResult` object is acquired by calling the :meth:`_engine.Result.scalars` method. A special limitation of :class:`_engine.ScalarResult` is that it has no ``fetchone()`` method; since the semantics of ``fetchone()`` are that the ``None`` value indicates no more results, this is not compatible with :class:`_engine.ScalarResult` since there is no way to distinguish between ``None`` as a row value versus ``None`` as an indicator. Use ``next(result)`` to receive values individually.

Method __init__ Undocumented
Method __iter__ Undocumented
Method __next__ Undocumented
Method all Return all scalar values in a list.
Method fetchall A synonym for the :meth:`_engine.ScalarResult.all` method.
Method fetchmany Fetch many objects.
Method first Fetch the first object or ``None`` if no object is present.
Method one Return exactly one object or raise an exception.
Method one_or_none Return at most one object or raise an exception.
Method partitions Iterate through sub-lists of elements of the size given.
Method unique Apply unique filtering to the objects returned by this :class:`_engine.ScalarResult`.
Class Variable __slots__ Undocumented
Class Variable _generate_rows Undocumented
Instance Variable _metadata Undocumented
Instance Variable _post_creational_filter Undocumented
Instance Variable _real_result Undocumented
Instance Variable _unique_filter_state Undocumented

Inherited from FilterResult:

Method __enter__ Undocumented
Method __exit__ Undocumented
Method close Close this :class:`_engine.FilterResult`.
Method yield_per Configure the row-fetching strategy to fetch ``num`` rows at a time.
Property closed Return ``True`` if the underlying :class:`_engine.Result` reports closed
Method _fetchall_impl Undocumented
Method _fetchiter_impl Undocumented
Method _fetchmany_impl Undocumented
Method _fetchone_impl Undocumented
Method _soft_close Undocumented
Property _attributes Undocumented
Property _soft_closed Undocumented

Inherited from ResultInternal (via FilterResult):

Method _allrows Undocumented
Method _column_slices Undocumented
Method _iter_impl Undocumented
Method _iterator_getter Undocumented
Method _manyrow_getter Undocumented
Method _next_impl Undocumented
Method _onerow_getter Undocumented
Method _only_one_row Undocumented
Method _raw_all_rows Undocumented
Method _row_getter Undocumented
Method _unique_strategy Undocumented
Class Variable _is_cursor Undocumented
Class Variable _row_logging_fn Undocumented
Class Variable _source_supports_scalars Undocumented

Inherited from InPlaceGenerative (via FilterResult, ResultInternal):

Method _generate Undocumented
def __init__(self, real_result: Result[Any], index: _KeyIndexType): (source)

Undocumented

def __iter__(self) -> Iterator[_R]: (source)

Undocumented

def __next__(self) -> _R: (source)

Undocumented

def all(self) -> Sequence[_R]: (source)

Return all scalar values in a list. Equivalent to :meth:`_engine.Result.all` except that scalar values, rather than :class:`_engine.Row` objects, are returned.

def fetchall(self) -> Sequence[_R]: (source)

A synonym for the :meth:`_engine.ScalarResult.all` method.

def fetchmany(self, size: Optional[int] = None) -> Sequence[_R]: (source)

Fetch many objects. Equivalent to :meth:`_engine.Result.fetchmany` except that scalar values, rather than :class:`_engine.Row` objects, are returned.

def first(self) -> Optional[_R]: (source)

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

def one(self) -> _R: (source)

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

def one_or_none(self) -> Optional[_R]: (source)

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

def partitions(self, size: Optional[int] = None) -> Iterator[Sequence[_R]]: (source)

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

def unique(self, strategy: Optional[_UniqueFilterType] = None) -> Self: (source)

Apply unique filtering to the objects returned by this :class:`_engine.ScalarResult`. See :meth:`_engine.Result.unique` for usage details.