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 needed this case today, I found the nice answer here:
So, we can make OR logic like the below example:
from sqlalchemy import or_
db.session.query(User).filter(or_(User.email=='useremail@example.com', User.name=="username")).first()
When using the filter()
expression, you must use proper comparison operators, whereas filter_by()
uses a shortened unPythonic form.