擅长:python、mysql、java
<p>我今天也需要这个案子,我找到了一个很好的答案<a href="http://www.leeladharan.com/sqlalchemy-query-with-or-and-like-common-filters" rel="nofollow noreferrer">here</a>:</p>
<p>因此,我们可以将<strong>或</strong>逻辑设为如下示例:</p>
<pre><code>from sqlalchemy import or_
db.session.query(User).filter(or_(User.email=='useremail@example.com', User.name="username")).first()
</code></pre>