我正在尝试从sqlalchemy CORE 查询的结果代理对象中检索dicts。
这是我能做的最好的事情:(而且我发现它非常蹩脚)
s = select([table])
results = connection.execute(s)
for r in results:
dict_ = dict(zip(r.keys(),r.values()))
我尝试使用其他问题中提及的.__dict__
和._asdict()
属性,但他们返回了错误Could not locate column in row for column
。有没有更惯用的方式将resukt检索为dict?我无法理解为什么默认行为是返回元组...