Thanks!

Yes, it is documented, and I tried to sift through the URLs before asking,
but it's kind of difficult (at least for me) to understand where exactly
should I be looking for a particular piece of introspection info.

 

From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On
Behalf Of Michael Bayer
Sent: Sunday, December 08, 2013 10:47 PM
To: sqlalchemy@googlegroups.com
Subject: Re: [sqlalchemy] m2m introspection

 

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=relat
ionships#sqlalchemy.orm.mapper.Mapper.relationships

http://docs.sqlalchemy.org/en/rel_0_9/orm/internals.html#sqlalchemy.orm.prop
erties.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 <viho...@gmail.com> 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 to <mailto:sqlalchemy+unsubscr...@googlegroups.com>
sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to  <mailto:sqlalchemy@googlegroups.com>
sqlalchemy@googlegroups.com.
Visit this group at  <http://groups.google.com/group/sqlalchemy>
http://groups.google.com/group/sqlalchemy.
For more options, visit  <https://groups.google.com/groups/opt_out>
https://groups.google.com/groups/opt_out.

 

-- 
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.

Reply via email to