![](/img/trans.png)
[英]Storing the results of a SQLAlchemy query to merge into another session
[英]Storing the results of a SQLAlchemy query in an array
我正在尝试将 SQLAlchemy 语句的结果存储在一个数组中。 但它给了我属性错误。 请帮忙。
qry = ( db.session.query(客户) )
print(qry)
results = [
{
"customerID": getModelField(row.Customer, "id"),
"network": getModelField(row.Customer, "network_num"),
"customer": getModelField(row.Customer,"customer_name"),
"email": getModelField(row.Customer, "customer_email"),
}
for row in qry.all()
]
out = {"results": results, "total": len(results)}
在控制台中,我得到 - AttributeError: 'Customer' object has no attribute 'Customer'
查询结果的每一行都是Customer
object。尝试row.id
作为您的 ID 等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.