扫码关注官方订阅号
在用sqlalchemy 查询数据的时候 想把数据中为 null的数据排除掉
session.query(employee).filter_by(brand_id is null)
这样不能用,求解。
光阴似箭催人老,日月如移越少年。
方法一
session.query(employee).filter_by(employ.brand_id.isnot(None))
方法二
from sqlalchemy import not_ session.query(employee).filter_by(not_(employ.brand_id==None))
参考http://docs.sqlalchemy.org/en/rel_1_0/core/sqlelement.html
django orm用法是session.query(employee).exclude(brand_id__isnull=True)
不知道sqlalchemy用法是怎样的。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
方法一
方法二
参考
http://docs.sqlalchemy.org/en/rel_1_0/core/sqlelement.html
django orm用法是
session.query(employee).exclude(brand_id__isnull=True)
不知道sqlalchemy用法是怎样的。