SQLAlchemy RowProxy到字典

时间:2018-08-03 00:54:22

标签: python sqlalchemy

如何将sqlalchemy.engine.result.RowProxy转换为字典?

row = db.engine.execute(sql, id=id).fetchone()

尝试使用SO question中的密码:

for c in inspect(obj).mapper.column_attrs:
    model_col = getattr(obj, c.key)
    model_dict[c.key] = model_col

错误:

sqlalchemy.exc.NoInspectionAvailable: No inspection system is available for object of type <class 'sqlalchemy.engine.result.RowProxy'>

0 个答案:

没有答案