I'm not sure I get your question...

if you have this already

children = relationship("Child")

what is it that you need to know??

By using MyClass.children you'll have access to it's children and they will
be, one2many relationships




On Wed, Dec 12, 2012 at 4:57 AM, AlexVhr <viho...@gmail.com> wrote:

> Hi all.
> I need to find out if a certain class has one-to-many relations to other
> classes, and what exactly this classes are. Something like this:
>
> *class* *Parent*(Base):****
>
>     __tablename__ = 'parent'****
>
>     id = Column(Integer, primary_key=True)****
>
>     children = relationship("Child")
>
>
> *class* *Child*(Base):****
>
>     __tablename__ = 'child'****
>
>     id = Column(Integer, primary_key=True)****
>
>     parent_id = Column(Integer, ForeignKey('parent.id'))****
>
>
> I'm kind of half way there:
>
>
> def findRelatedClasses(cls):****
>
>     #iterate cls.__dict__, find a class member with****
>
>     #property.direction.name == ‘ONETOMANY’.****
>
>     #Now, to find out which class it links to…****
>
> ** **
>
> findRelatedClasses(Parent) should return a list of type objects ([Child]
> in this instance). Any ideas how to do that? Thanks!****
>
> --
> 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/-/LaLdjo3_XoUJ.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to