如何InstrumentedAttribute在SQLalchemy中获取对象的值:
(Pdb) ResultLine.item_reference_1
<sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x793dc90>
Run Code Online (Sandbox Code Playgroud)
上面的语句向我显示sqlalchemy对象。
我真正需要的是与之相关的价值。
没有与关联的值InstrumentedAttribute;您正在查看表声明,而不是结果集。InstrumentedAttribute例如,用于定义与另一个表的关系。
在数据库中查询结果,结果对象将为您填充参考:
for res in session.query(ResultLine).filter(somefilter):
print res.item_reference_1
Run Code Online (Sandbox Code Playgroud)