SQLAlchemy Core select where condition contains boolean expression `is False`

前端 未结 2 1733
Happy的楠姐
Happy的楠姐 2020-12-18 14:35

How to use SQLAlchemy expression language to select columns with where condition to check boolean expression. example:

select([table]).\\
    where(and_(tabl         


        
2条回答
  •  醉酒成梦
    2020-12-18 15:03

    According to the documentation, the way you should handle this is by using the true() or false() constants that you can import from SqlAlchemy. It would look like this:

    from sqlalchemy import false
    
    select([table]).\
        where(and_(table.c.col1 == 'abc',
                   table.c.is_num == false() 
        ))
    

    Hope this helps!

提交回复
热议问题