如何在Python Peewee ORM中用`WHERE value IN list`做查询? [英] How to do query with `WHERE value IN list` in the Python Peewee ORM?

查看:1006
本文介绍了如何在Python Peewee ORM中用`WHERE value IN list`做查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Flask项目使用了(真棒)Python Peewee ORM,但是现在我试图用一个来查询其中['a','b',' C'] 。我尝试这样做,如下所示:

pre $ My $ My $ My $ My $ My $ My $ My $ My $ My $ My $ My $ My $ '])

但不幸的是,它返回数据库中的所有记录。任何想法,我可以做到这一点?

解决方案

你读过 docs
$ b

MyModel.select()。其中(MyModel.sell_currency<< ['BTC','LTC'])


I'm using the (awesome) Python Peewee ORM for my Flask project, but I now got stuck trying to do a query with a where value in ['a', 'b', 'c']. I tried doing it as follows:

MyModel.select().where(MyModel.sell_currency in ['BTC', 'LTC'])

But unfortunately it returns all records in the DB. Any ideas how I could do this?

解决方案

Have you read the docs?

MyModel.select().where(MyModel.sell_currency << ['BTC', 'LTC'])

这篇关于如何在Python Peewee ORM中用`WHERE value IN list`做查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆