MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / one

Method one

lib/sqlalchemy/orm/query.py:2851–2872  ·  view source on GitHub ↗

Return exactly one result or raise an exception. Raises :class:`_exc.NoResultFound` if the query selects no rows. Raises :class:`_exc.MultipleResultsFound` if multiple object identities are returned, or if multiple rows are returned for a query that returns only scal

(self)

Source from the content-addressed store, hash-verified

2849 return self._iter().one_or_none() # type: ignore
2850
2851 def one(self) -> _T:
2852 """Return exactly one result or raise an exception.
2853
2854 Raises :class:`_exc.NoResultFound` if the query selects no rows.
2855 Raises :class:`_exc.MultipleResultsFound` if multiple object identities
2856 are returned, or if multiple rows are returned for a query that returns
2857 only scalar values as opposed to full identity-mapped entities.
2858
2859 Calling :meth:`.one` results in an execution of the underlying query.
2860
2861 .. seealso::
2862
2863 :meth:`_query.Query.first`
2864
2865 :meth:`_query.Query.one_or_none`
2866
2867 :meth:`_engine.Result.one` - v2 comparable method.
2868
2869 :meth:`_engine.Result.scalar_one` - v2 comparable method.
2870
2871 """
2872 return self._iter().one() # type: ignore
2873
2874 def scalar(self) -> Any:
2875 """Return the first element of the first result or None

Calls 1

_iterMethod · 0.95