Hi Michael,
thank you for the quick answer. object_mapper() solves
the UnmappedClassError.
The depicted technique, however, lists just the 'physical' columns. Those
defined with relationship() or injected by backref are not included.
I'm not Luke, but I also used the source (thank you for providing it) ;)
which pointed me to sqlalchemy.orm.properties.RelationshipProperty. With
this I am able to list both kinds of columns:
mapper = object_mapper(p)
attrs = []
for prop in mapper.iterate_properties:
if isinstance(prop, ColumnProperty):
attrs.append(prop.key)
elif isinstance(prop, RelationshipProperty):
attrs.append(prop.key)
attrs.sort()
print "Columns:", attrs
Regards, Dirk
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/uXzxYvZBlQoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.