# Import sqlalchemy so we can use it
import sqlalchemy as sa
# Rename the OP's object to `obj`
obj = usersModelInstance
# Build a list of only relationship properties
relation_properties = filter(
lambda p: isinstance(p, sa.orm.properties.RelationshipProperty),
sa.orm.object_mapper(obj).iterate_properties
)
我不太确定你想要一个表列表还是一个映射类列表?在
无论哪种情况,首先为映射的对象构建一个属性列表:
请注意,如果不使用
sa.orm.class_mapper(cls)
函数,则可以使用该函数 当前有一个实体实例的句柄,但只有一个映射类。在现在,在第一种情况下,您需要相关表的列表,请执行以下操作:
^{pr2}$在第二种情况下,您可能需要相关映射类的列表, 执行:
希望这能让你开始。在
相关问题 更多 >
编程相关推荐