gpt4 book ai didi

python - 获取 SQLalchemy 检测属性的值

转载 作者:太空宇宙 更新时间:2023-11-04 09:12:14 24 4
gpt4 key购买 nike

如何在 SQLalchemy 中获取 InstrumentedAttribute 对象的值:

(Pdb) ResultLine.item_reference_1
<sqlalchemy.orm.attributes.InstrumentedAttribute object at 0x793dc90>

上面的语句向我打印了 sqlalchemy 对象。

我真正需要的是与之相关的值(value)。

最佳答案

InstrumentedAttribute 没有关联的值;您正在查看表声明,而不是结果集。例如,InstrumentedAttribute 用于定义与另一个表的关系。

查询数据库以获取结果,结果对象将为您填写引用:

 for res in session.query(ResultLine).filter(somefilter):
print res.item_reference_1

关于python - 获取 SQLalchemy 检测属性的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13582111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com