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