I need to select all cells containing the values ββ"Null" or "0".
Using | as a logical OR
Node.query.filter((Node.maintenance == None) | (Node.maintenance == 0))
Using is_(None)
Or, to avoid using == None (due to lint)
Node.query.filter((Node.maintenance.is_(None)) | (Node.maintenance == 0))
Using or_
Or this form
from sqlalchemy import or_ Node.query.filter(or_(Node.maintenance == None, Node.maintenance == 0))
Using in_
If you are wondering if you can request the use of something similar to the in operator in SQL and Python, you are correct, you can do it in SQLAlchemy too, but unfortunately it does not work for None/NULL values , but for illustration we can see that
Node.query.filter(Node.maintenance.in_([0, 1]))
equivalently
Node.query.filter((Node.maintenance == 0) | (Node.maintenance == 1))
source share