On Wednesday, January 2, 2013 1:39:28 PM UTC-3, Michael Bayer wrote: > > > On Jan 2, 2013, at 8:33 AM, John Anderson wrote: > > I would like to generate this query: > > SELECT a.pk, aa.response > FROM attendee as "a" > JOIN field as "f" on f.conference_pk = a.conference_pk > LEFT JOIN attendee_answer as "aa" ON aa.field_pk = f.pk > AND aa.attendee_pk = a.pk; > > Using the ORM, I came up with: > > onclause = and_( > AttendeeAnswer.field_pk==Field.pk, AttendeeAnswer.attendee_pk > == Attendee.pk > ) > > query = self.session.query(Attendee).join( > Field, Field.conference_pk == Attendee.conference_pk > ).outerjoin( > (AttendeeAnswer, onclause) > ).add_entity( > AttendeeAnswer > ).filter( > Attendee.conference_pk == conference_pk > ) > > results = query.all() > > But this returns separate ORM objects, but in this specific case I would > just like the results in a list containing the data results, rather than > individual ORM objects. Is there a way to do this or should I just pass > my select statement to execute? > > > you can specify the columns: > > q = session.query(Attendee.pk, AttendeeAnswer.response)... > > > Is there a way to do Attendee.*, AttendeeAnswer.response instead of listing all individually?
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/Neoy5pVxvGIJ. 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.
