1. Flask 数据库过滤条件
eq
not eq
like
in
not in
and
or
is null
is not null
in 和not in 还有用法, 在前面加上~,表示一次否定,即 ~ user.title.not in_ 表示双重否定,即=in
注意, Null 没有占数据库表格中的位置,而none 为空,相当于空的字符串,是占用了表格中的位置的。
is not null的写法还有:
query.filter(User.name !=None)
或者
query.filter(User.name isnot(None))
and
or
这两个方法都需要导入,所以在最上方导入时需要写成and_ or_
3种and方式写