Hello list,
I don't think my brain is currently capable of figuring out the SQL
itself, let alone how to do it with SQLA.
I've got the following models:
City
Location
Item
Category
Location belongs to one of many Cities via simple Location.city_id
foreign key
Location belongs to one or more Categories via LocationCategoryAssoc
relationship(secondary) many-to-many
Item belongs to one or more Location via LocationItemAssoc
relationship(secondary) many-to-many
I need to list Items that:
- have Item.some_flag == True
- are present in Location X (have relationship with Location.id == X)
- belong to Category Y (have relationship with Category.category_id == Y)
Affected properties:
City.city_id
Category.category_id
Location.city_id
LocationCategoryAssoc.location_id (fkey to Location)
LocationCategoryAssoc.category_id (fkey to Category)
LocationItemAssoc.location_id (fkey to Location)
LocationItemAssoc.item_id (fkey to Item)
Item.some_flag
The Item.some_flag == True is simple, of course, but I'm not sure how to
construct the query, joins and filters for the rest. The result I want
is a list of Item instances.
Many thanks.
--
.oO V Oo.
Work Hard,
Increase Production,
Prevent Accidents,
and
Be Happy! ;)
--
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.