with modern sqlalchemy do this:

from sqlalchemy import inspect

for rel in inspect(MyClass).relationships:
   target_class = rel.mapper.class_

this stuff is all documented, though it involves familiarizing with a few basic 
constructs like Mapper and RelationshipProperty:

http://docs.sqlalchemy.org/en/rel_0_9/core/inspection.html?highlight=inspect#sqlalchemy.inspection
http://docs.sqlalchemy.org/en/rel_0_9/orm/mapper_config.html?highlight=relationships#sqlalchemy.orm.mapper.Mapper.relationships
http://docs.sqlalchemy.org/en/rel_0_9/orm/internals.html#sqlalchemy.orm.properties.RelationshipProperty.mapper
http://docs.sqlalchemy.org/en/rel_0_9/orm/mapper_config.html#sqlalchemy.orm.mapper.Mapper.class_

On Dec 8, 2013, at 5:55 AM, Alexey Vihorev <[email protected]> wrote:

> Hi again!
> I can do MyClass.iterate_properties()and check if a property is m2m 
> relationship. But how can I find out which class it references? 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 [email protected].
> To post to this group, send email to [email protected].
> 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