Peewee 如何通过变量设置查询的运算符和逻辑?

Peewee how to set query's operators and logics by variable?

我想用 peewee 动态构建查询。

示例查询:

User.select()
    .where(
        (User.full_name=="test") | 
        (User.email=="test")
    )

有这样的可能吗?

op1 = "=="
op2 = "!="
logic = "|"
User.select()
    .where(
        (User.full_name op1 "test") logic
        (User.email op2 "test")
    )

可以使用算子模块

import operator
name_is_test = operator.eq(User.full_name, 'test')
email_is_test = operator.eq(User.email, 'test')
User.select().where(operator.or_(name_is_test, email_is_test)