Hi!
This is category table:
t_category = sa.Table("categories", meta.metadata,
sa.Column("id", sa.types.Integer, primary_key=True,
autoincrement=True),
sa.Column("parent_id", sa.types.Integer(), sa.ForeignKey
("categories.id"), nullable=True)
...
)
and relation:
orm.mapper(Category, t_category, properties = {
'parent_category' : orm.relation(Category, uselist=False,
remote_side=[t_category.c.id]),
'subcategories': orm.relation(Category,
backref='Category_SubCategories', cascade='all, delete', remote_side=
[t_category.c.id]) # ?????
})
And my question is how to create relation between category and
children (subcategories) to get subcategories, for example:
for subcategory in category.subcategories:
print subcategory.name
?? :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---