peewee Model.get的复杂查询

(a | b )&c

官方文档没有具体讲到,又没有太多时间来看源码。经过尝试,

 (a | b) and c

(a or b) and c

都是可以的。

而  (a | b) &c 是不行的

    (a or b)&c 也不行。

 

=====================

后记:上面的错了。peewee的Model.get不支持条件的or操作。

 

and操作用逗号代替。

 

=======

备注:or可以写进去,但出来的东西很奇怪

and也可以连着写。出来的结果不对。

 

-----------------------------------------

后记:

peewee的sql操作符对应:http://peewee.readthedocs.org/en/latest/peewee/querying.html#query-operators

ComparisonMeaning
==x equals y
<x is less than y
<=x is less than or equal to y
>x is greater than y
>=x is greater than or equal to y
!=x is not equal to y
<<x IN y, where y is a list or query
>>x IS y, where y is None/NULL
%x LIKE y where y may contain wildcards
**x ILIKE y where y may contain wildcards
~Negation

 

sqlQuery.where中的or操作demo(这个总是忘):

Tweet.select().join(User).where(
    (User.is_staff == True) | (User.is_superuser == True)

 

转载于:https://www.cnblogs.com/Tommy-Yu/p/4411502.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值