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.
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
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
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
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:
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
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'