Return exactly one row or raise an exception. Raises :class:`_exc.NoResultFound` if the result returns no rows, or :class:`_exc.MultipleResultsFound` if multiple rows would be returned. .. note:: This method returns one **row**, e.g. tuple, by default. T
(self)
| 1085 | ) |
| 1086 | |
| 1087 | def one(self) -> Row[Unpack[_Ts]]: |
| 1088 | """Return exactly one row or raise an exception. |
| 1089 | |
| 1090 | Raises :class:`_exc.NoResultFound` if the result returns no |
| 1091 | rows, or :class:`_exc.MultipleResultsFound` if multiple rows |
| 1092 | would be returned. |
| 1093 | |
| 1094 | .. note:: This method returns one **row**, e.g. tuple, by default. |
| 1095 | To return exactly one single scalar value, that is, the first |
| 1096 | column of the first row, use the |
| 1097 | :meth:`_engine.Result.scalar_one` method, or combine |
| 1098 | :meth:`_engine.Result.scalars` and |
| 1099 | :meth:`_engine.Result.one`. |
| 1100 | |
| 1101 | .. versionadded:: 1.4 |
| 1102 | |
| 1103 | :return: The first :class:`_engine.Row`. |
| 1104 | |
| 1105 | :raises: :class:`.MultipleResultsFound`, :class:`.NoResultFound` |
| 1106 | |
| 1107 | .. seealso:: |
| 1108 | |
| 1109 | :meth:`_engine.Result.first` |
| 1110 | |
| 1111 | :meth:`_engine.Result.one_or_none` |
| 1112 | |
| 1113 | :meth:`_engine.Result.scalar_one` |
| 1114 | |
| 1115 | """ |
| 1116 | return self._only_one_row( |
| 1117 | raise_for_second_row=True, raise_for_none=True, scalar=False |
| 1118 | ) |
| 1119 | |
| 1120 | # special case to handle mypy issue: |
| 1121 | # https://github.com/python/mypy/issues/20651 |
nothing calls this directly
no test coverage detected