How can I add the filter as in SQL to select values that are NOT NULL from a certain column ?
SELECT *
FROM table
WHERE YourColumn IS NOT NULL;
How can I do the same with SQLAlchemy filters?
select = select(table).select_from(table).where(all_filters)
In case anyone else is wondering, you can use
is_
to generatefoo IS NULL
:column_obj != None
will produce aIS NOT NULL
constraint:or use
isnot()
(new in 0.7.9):Demo:
Starting in version 0.7.9 you can use the filter operator
.isnot
instead of comparing constraints, like this:query.filter(User.name.isnot(None))
This method is only necessary if pep8 is a concern.
source: sqlalchemy documentation