What might work for you (if the database is structured as such) would be
something like this (in pseudocode)
class ProductAttribute(base):
id = column-int, primary key
name = column-unicode
class Product2ProductAttribute(base):
product_id =column-int, part of primary key
product_attribute_id = column-int, part of primary key
product = orm.relationship('Product')
product_attribute = orm.relationship('ProductAttribute')
class Product(base):
id = column-int, primary key
to_attributes = orm.relationship('Product2ProductAttribute')
# this would generate a huge sql matrix like you are now
products = session.query(Product).options(joinedload('to_attributes'),
joinedload("to_attributes.product_attribute"))
for product in products:
# the product data
print product
# loop the attributes
for to_attribute in product.to_attributes:
print to_attribute.product_attribute.name
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.