On 21/11/2013 19:25, Michael Bayer wrote:

hoping you’ve already figured it out but otherwise I’m not entirely following 
what the larger query you’re looking for would look like.    I doubt you need 
text() for anything.

Okay, pseudo code that doesn't work:

positions = something("""
select instrument_id, sum(quantity) as quantity
        from transaction where
            account_id = :account_id and
            timestamp < :dt and
        group by instrument_id
        having sum(quantity) != 0
""", dict(dt=date(2013, 1, 1), account_id='foo')).cte('positions')

print session.query(Instrument, positions.c.quantity)\
       .select_from(Instrument)\
       .join(positions, Instrument.id=positions.instrument_id)\
       .all()

(this latter query will likely have more stuff in it, not sure I used .select_from(...).join(...) correctly either ;-)

Hope that illustrates what I'm after...

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk

--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to