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'))
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 sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
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:
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/-/L_y3F-9AOWAJ.