我有这个问题,我不明白。
我有SELECT()
返回数千行的查询。对于内存问题,我让它一次返回一个结果行。然后我将结果转换为字典。
select_query = select([table1,table2]).where(all_filters)
res = conn.execute(select_query)
row = res.fetchone()
while row is not None:
row = res.fetchone()
print row is None
结果是:
False
False
False
False
True
为什么即使它应该在什么时候停止它仍然显示为真row is None
?
所以后来当我想使用创建一个字典时:row = dict(zip(row.keys(), row))
我得到了错误:AttributeError: 'NoneType' object has no attribute 'keys'
我是 Python 新手,任何帮助将不胜感激。