take a look at local_columns, remote_side, local_remote_pairs (all views of the 
same thing):

MyClass.attribute.property.local_remote_pairs

that gives you Column objects.   If your mappings have attributes without the 
same names, you can relate them together mapper.get_property_by_column() where 
mapper is via inspect:

from sqlalchemy import inspect
mapper = inspect(MyRemoteClass)

for local, remote in MyLocalClass.attribute.property.local_remote_pairs:
    prop = mapper.get_property_by_column(remote)
    class_attr = prop.class_attribute   # same as MyRemoteClass.someattribute
    key = prop.key
    # etc



On Oct 11, 2013, at 11:01 PM, Alexey Vihorev <viho...@gmail.com> wrote:

> Hi!
> I’m trying to do some introspection on a class’s one-to-many relationships. 
> I’m trying to find out which attribute in “many” table points to the “one” 
> table. Is that possible? Thanks!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to