SQLAlchemy has nice documentation.
one()
Return exactly one result or raise an exception.
Raises sqlalchemy.orm.exc.NoResultFound if the query selects no rows.
Raises sqlalchemy.orm.exc.MultipleResultsFound if multiple object
identities are returned, or if multiple rows are returned for a query
that returns only scalar values as opposed to full identity-mapped
entities.
Link on one() method
scalar()
Return the first element of the first result or None if no rows
present. If multiple rows are returned, raises MultipleResultsFound.
Link on scalar() method.
and if you will have some questions related to SQLAlchemy my recommendation – first of all, to check the documentation, since it’s really powerful and clean.
UPD:
Since the answer contains old links and for the 1.4 version of SQLAlchemy.
Here are links for version 2.0
- Query.scalar()
- Query.one()