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

Method first

lib/sqlalchemy/engine/result.py:1388–1399  ·  view source on GitHub ↗

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.

(self)

Source from the content-addressed store, hash-verified

1386 return self._next_impl()
1387
1388 def first(self) -> Optional[_R]:
1389 """Fetch the first object or ``None`` if no object is present.
1390
1391 Equivalent to :meth:`_engine.Result.first` except that
1392 scalar values, rather than :class:`_engine.Row` objects,
1393 are returned.
1394
1395
1396 """
1397 return self._only_one_row(
1398 raise_for_second_row=False, raise_for_none=False, scalar=False
1399 )
1400
1401 def one_or_none(self) -> Optional[_R]:
1402 """Return at most one object or raise an exception.

Callers

nothing calls this directly

Calls 1

_only_one_rowMethod · 0.80

Tested by

no test coverage detected