gpt4 book ai didi

python - Peewee:减少条件语句在一定长度后中断的位置

转载 作者:行者123 更新时间:2023-12-01 04:39:46 25 4
gpt4 key购买 nike

这就是我所拥有的:

SomeTable.select.where(reduce(operator.or_, (SomeTable.stuff == entry for entry in big_list)))

当我在 big_list 中有一个相对较大的元素列表时,问题就出现了,我得到了这个:

RuntimeError: maximum recursion depth exceeded

是否有另一种方法可以解决这个问题,而不需要将列表分成几个 block ?

尝试使用任何建议,这是我的错误:

Traceback (most recent call last):
File "C:/Users/f9xk3li/Documents/GitHub/leoshop_web/leoshop_web/data_models/data_model.py", line 347, in <module>
search_bins_all("BoA 0")
File "C:/Users/f9xk3li/Documents/GitHub/leoshop_web/leoshop_web/data_models/data_model.py", line 179, in search_bins_all
for d in generator.order_by(SomeTable.RetrievedDate.desc()):
File "C:\Users\f9xk3li\AppData\Local\Continuum\Anaconda\lib\site-packages\peewee.py", line 282, in inner
clone = self.clone() # Assumes object implements `clone`.
File "C:\Users\f9xk3li\AppData\Local\Continuum\Anaconda\lib\site-packages\peewee.py", line 2202, in clone
return self._clone_attributes(query)
File "C:\Users\f9xk3li\AppData\Local\Continuum\Anaconda\lib\site-packages\peewee.py", line 2412, in _clone_attributes
query = super(SelectQuery, self)._clone_attributes(query)
File "C:\Users\f9xk3li\AppData\Local\Continuum\Anaconda\lib\site-packages\peewee.py", line 2206, in _clone_attributes
query._where = self._where.clone()
AttributeError: 'bool' object has no attribute 'clone'

这是代码

generator = SomeTable.select()
generator = generator.where(any(SomeTable.BIN == entry for entry in big_list))
for d in generator:
....

最佳答案

尝试...where(SomeTable.BIN.in_(big_list))

PeeWee 对于在其 where 子句中使用的内容有限制,以便与库一起使用。

http://docs.peewee-orm.com/en/latest/peewee/querying.html#query-operators

关于python - Peewee:减少条件语句在一定长度后中断的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30982571/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com