I have a Flask project that interacts with MySQL
db through Flask-SQLAlchemy
.
My question is, how to select a row from the database based on a v
I also wanted to have an or
along with and
condition
I found this after googling around:
# Users whose age is 23 AND (firstname IS alex OR lastname IS watson)
usrs = session.query(User) \
.filter(User.age === "23") \
.filter((User.firstname == 'alex') | (User.lastname == 'watson')) \
.all()
hopefully, it helps other people coming here looking for it