查询似乎没问题,当我将布尔值过滤为False时,它工作正常,但是当查询返回布尔值为True的项目时,它给了我这个异常。
query = session.query(URL).filter_by(status_code=200,
content_type='text/html',
is_phish_whitelist=True,
is_phish_google_safebrowsing=None,
is_malware_google_safebrowsing=None)
Traceback (most recent call last):
File "/home/user/PycharmProjects/poc/collector/verify_googlesafe.py", line 25, in <module>
phish_urls = phish_query.all()
File "/home/user/Envs/poc/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2237, in all
return list(self)
File "/home/user/Envs/poc/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 72, in instances
rows = [process[0](row, None) for row in fetch]
File "/home/user/Envs/poc/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 447, in _instance
populate_state(state, dict_, row, isnew, only_load_props)
File "/home/user/Envs/poc/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 301, in populate_state
populator(state, dict_, row)
File "/home/user/Envs/poc/local/lib/python2.7/site-packages/sqlalchemy/orm/strategies.py", line 150, in fetch_col
dict_[key] = row[col]
ValueError: int_to_boolean only accepts None, 0 or 1
编辑:
我已经安装了没有 C 扩展的 SQLAlchemy,并且一切正常,所以它看起来像 C 扩展中的一个错误。我要向他们报告这件事,看看他们怎么说。
pip install --global-option='--without-cextensions' SQLAlchemy