5
我有一個數據庫,「新聞」通過SQLAlchemy的創建:SQLAlchemy的布爾值沒有定義
class News(Base):
__tablename__ = "news"
id = Column(Integer, primary_key = True)
title = Column(String)
author = Column(String)
url = Column(String)
comments = Column(Integer)
points = Column(Integer)
label = Column(String)
我也有一個函數f(職稱),即獲得一個字符串並返回的3個變種一個字符串:「好」,「可能」或「從不」。 我試圖讓過濾行:
rows = s.query(News).filter(News.label == None and f(News.title)=='good').all()
但是程序失敗,提出這個錯誤:
raise TypeError("Boolean value of this clause is not defined")
我怎麼能resovle呢?
@IljaEverilä你應該張貼,作爲一個答案,我幾乎錯過您的評論,並已寫同樣的事情。 –
我試圖找到一個現有的重複,但有些驚喜不能。 –