Reputation: 59
This is my query
exist = db.session.query((exists().where(CreateUser.email == email) & (CreateUser.password == password))).scalar()
But I get this error:
sqlalchemy.orm.exc.MultipleResultsFound
My semantic is, it should check if the email and password exist from the table but I get this error.
What am I doing wrong?
Upvotes: 1
Views: 486
Reputation: 15090
You need to put brackets around whereclause
exist = db.session.query((exists().where( (CreateUser.email == email) & (CreateUser.password == password) ))).scalar()
Upvotes: 1
Reputation: 1194
The exists()
function returns a boolean. If you want to return a single row, just do this:
session.query(User).filter(User.email == email).filter(User.password == password).first()
Upvotes: 0