[sqlalchemy] Re: JOIN to subquery in mapper

2008-11-19 Thread indigophone
formulate the query and its   relation to the parent in exactly the way you need. On Nov 18, 2008, at 9:34 PM, indigophone wrote: zipcode_meta_join_subquery = session.query(us_zipcode_table.c.city_id, us_zipcode_table.c.zipcode_population, us_zipcode_table.c.average_house_value).group_by

[sqlalchemy] JOIN to subquery in mapper

2008-11-18 Thread indigophone
zipcode_meta_join_subquery = session.query(us_zipcode_table.c.city_id, us_zipcode_table.c.zipcode_population, us_zipcode_table.c.average_house_value).group_by(us_zipc ode_table.c.city_id).subquery() mapper(USCity, us_city_table, properties={ 'state':relation(USState,

[sqlalchemy] distance calculation and ORM

2008-11-15 Thread indigophone
I have the following query: SET @lat = 40.81518; SET @lon = -73.0455; SELECT 3963.0 * acos(sin(@lat/57.2958) * sin(z.latitude/57.2958) + cos(@lat/ 57.2958) * cos(z.latitude/57.2958) * cos(z.longitude/57.2958 - @lon/ 57.2958)) AS distance, fa.advisor_id, c.city_name, s.iso_state_name FROM