Getting first row from sqlalchemy

后端 未结 4 1720
半阙折子戏
半阙折子戏 2020-12-13 17:13

I have the following query:

profiles = session.query(profile.name).filter(and_(profile.email == email, profile.password == password_hash))

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 17:40

    Use one_or_none(). Return at most one result or raise an exception.

    Returns None if the query selects no rows.

提交回复
热议问题