MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / one_or_none

Method one_or_none

lib/sqlalchemy/engine/result.py:1706–1716  ·  view source on GitHub ↗

Return at most one object or raise an exception. Equivalent to :meth:`_engine.Result.one_or_none` except that :class:`_engine.RowMapping` values, rather than :class:`_engine.Row` objects, are returned.

(self)

Source from the content-addressed store, hash-verified

1704 )
1705
1706 def one_or_none(self) -> Optional[RowMapping]:
1707 """Return at most one object or raise an exception.
1708
1709 Equivalent to :meth:`_engine.Result.one_or_none` except that
1710 :class:`_engine.RowMapping` values, rather than :class:`_engine.Row`
1711 objects, are returned.
1712
1713 """
1714 return self._only_one_row(
1715 raise_for_second_row=True, raise_for_none=False, scalar=False
1716 )
1717
1718 def one(self) -> RowMapping:
1719 """Return exactly one object or raise an exception.

Callers

nothing calls this directly

Calls 1

_only_one_rowMethod · 0.80

Tested by

no test coverage detected