I am querying a database with psycopg2 and python3 to get decimal arrays.
Inside the DB I am concatenating arrays with an aggregate functions like the one shown here.
From reading the psycopg2 documentation I was under the impression PostgreSQL decimal arrays should be getting converted to python decimal lists by default, but this is not happening. I am getting a single string instead.
Here is an example return value:
{"(\"{1.33,1.37,1.5,1.1,1.576...
Do I need to create a custom type-caster as outlined here on the documentation? If so, can someone point me in the right direction of how to do it because so far I am getting nowhere.
Alternative suggestions welcome. Ultimately i want these arrays in numpy objects for manipulation and plotting.
EDIT:
Ok, further digging leads me to the conclusion the issue is my aggregate function in the DB. I am using one identical to that shown in this stackoverflow question.
CREATE AGGREGATE array_accum(anyarray) (
SFUNC = array_cat,
STYPE = anyarray,
INITCOND = '{}'
);
The return from this is coming as a string however.
I am calling it just like in the question linked above:
SELECT array_accum( ARRAY[[x,x]] )
FROM (SELECT subseries FROM series
WHERE offset BETWEEN 10 AND 20) x;
If I query for an individual subseries I am getting the correct type. After aggregation it is being converted to a string however.