[sqlalchemy] Re: JOIN to subquery in mapper

2008-11-19 Thread indigophone
I gave it a shot but I am no closer to knowing how to do this. On Nov 19, 12:00 am, Michael Bayer [EMAIL PROTECTED] wrote: joining to a subquery is better accomplished outside of relation()   using query, such as query(USZipCode).join((subquery,   subquery.c.col==USZipCode.somecol)). Now

[sqlalchemy] Re: JOIN to subquery in mapper

2008-11-19 Thread Michael Bayer
its impossible to know what you want without seeing literal SQL but this is the general idea from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class USCity(Base): __tablename__ = 'cities' id =

[sqlalchemy] Re: JOIN to subquery in mapper

2008-11-18 Thread Michael Bayer
joining to a subquery is better accomplished outside of relation() using query, such as query(USZipCode).join((subquery, subquery.c.col==USZipCode.somecol)). Now you want it as an attribute on your class. Do it like this: class USCity(object): ... @property def