sqlalchemy IS NOT NULL select

前端 未结 3 1852
走了就别回头了
走了就别回头了 2020-12-23 13:00

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;
         


        
3条回答
  •  一生所求
    2020-12-23 13:35

    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

提交回复
热议问题