[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-15 Thread David Gardner
Thanks for the tip about TypeDecorator I got it working to parse up the string, still not sure why SA is returning a string and not a tuple of integers, but at this point I have a good work-around and I'm happy. Especially since TypeDecorator allows me to return those numbers as a dictionary.

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-15 Thread Conor
David Gardner wrote: Thanks for the tip about TypeDecorator I got it working to parse up the string, still not sure why SA is returning a string and not a tuple of integers, but at this point I have a good work-around and I'm happy. Especially since TypeDecorator allows me to return those

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-15 Thread David Gardner
Aha! thanks for the tip. You are right, because that is the way psql returns it. I re-wrote my PostgreSQL function to return an array of bigint, which then psycopg2 and SQLAlchemy see as an array of integers, which works out really great for me. I don't think SA is at fault: I believe that

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread Michael Bayer
David Gardner wrote: I have a PostgreSQL function that returns a composite type (a text field and 6 bigint columns). Currently I am calling it with: session.query(Job,func.farm.call_job_status(Job.path)).filter(Job.path=='testshow').first() Which returns a tuple, but the second element is

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread David Gardner
I have a composite type that I defined as: CREATE TYPE farm.job_status_ret AS (total bigint, valid bigint, invalid bigint, processing bigint, pending bigint, canceled bigint); I dropped the text field. When I run the query in postgres I get the six distinct fields:

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread Michael Bayer
David Gardner wrote: I have a composite type that I defined as: CREATE TYPE farm.job_status_ret AS (total bigint, valid bigint, invalid bigint, processing bigint, pending bigint, canceled bigint); I dropped the text field. When I run the query in postgres I get

[sqlalchemy] Re: sqlalchemy.sql.expression.func and composite types

2009-10-14 Thread David Gardner
Did a quick test using psycopg2 and it returns a tuple of six longs: (9892718L, 1046L, 189L, 235L, 9890143L, 1105L) --- import psycopg2 import psycopg2.extensions DB_HOST = 'localhost' DB_NAME = 'hdpsdb' DB_USER = 'testuser' DB_PASS = 'testuser' db_uri = dbname='%s'