[英]How do you run an OR query in Peewee ORM?
I'd like to run a query for a user based on username or email address.我想根据用户名或电子邮件地址对用户运行查询。
I must be missing it, but I can't find how to run an OR
query in the peewee documentation.我一定是遗漏了它,但我在 peewee 文档中找不到如何运行OR
查询。 How do you do that?你是怎样做的?
From the documentation从文档
If you want to express a complex query, use parentheses and python's bitwise or and and operators:如果要表达复杂的查询,请使用括号和 python 的按位或和和运算符:
>>> Tweet.select().join(User).where(
... (User.username == 'Charlie') |
... (User.username == 'Peewee Herman')
... )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.