Hi All.

I have a problem with that query, how to rewrite it using sqlalchemy?

What to do with tuples - "array_agg(row(meter_id,
organization_reading, reading)::meterreading)" in psql I see it like
{"(499680,137,141)","(500765,258,267)"} ?
And composite custom type - "meterreading" ?

How to create that type? And how to access array of tuples is it
supported with sqlalchemy multi-dimesional ARRAY type?

CREATE TYPE meterreading AS (
    meter_id VARCHAR(255),
    organization_reading INTEGER,
    reading INTEGER);

SELECT t.*,
              m.readings
FROM transactions t
           LEFT OUTER JOIN
             (SELECT office_id, serial, commit_date, service_id,
                            array_agg(row(meter_id,
organization_reading, reading)::meterreading) AS readings
              FROM meter_readings
              GROUP BY office_id, serial, commit_date, service_id) m
          USING (office_id, serial, commit_date, service_id)
WHERE commit_date = '2010-01-11';

Thanks a lot!
-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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.


Reply via email to