from sqlalchemy.orm.exc import MultipleResultsFound
try:
    user = session.query(User).one()
except MultipleResultsFound as e:
    print(e)
except NoResultFound as e:
    print(e)
Получение первой строки из sqlalchemy