後條件語句打破這是我有:Peewee:減少其中一定長度
SomeTable.select.where(reduce(operator.or_, (SomeTable.stuff == entry for entry in big_list)))
的問題,當我在big_list元素的相對大名單出現,我得到這個:
RuntimeError: maximum recursion depth exceeded
有沒有另一種方法可以解決這個問題,不需要將列表分成幾個塊?
試過建議使用任何,這是我的錯誤:
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:
....
哦,上帝,我爲什麼甚至可以編寫的東西,簡單的......我不記得曾經在文檔TT –
我也碰上了「變數太多」的錯誤看到.in_這樣一個複雜的解決方案,但這是一個SQLite的限制,據說,這是非常好的! –
如果你可以將'big_list'替換爲PeeWee查詢,那麼我相信它會在數據庫中完全查找,這可能會處理「太多變量」錯誤。 我今天第一次只瀏覽PeeWee文檔,並且我不熟悉sqlite錯誤,但如果這是我的想法,那麼我很確定這會幫助你。 –