Re: Using a psycopg2 converter to retrieve bytea data from PostgreSQL

From: Andy Casey <andycasey(at)gmail(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: Using a psycopg2 converter to retrieve bytea data from PostgreSQL
Date: 2012-05-21 04:32:55
Message-ID: 71DB388E-5985-4978-878B-7B921A34FEEA@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hi,

I'm just re-raising this problem to anyone on the mailing list, because I haven't had any luck on StackOverflow, or any suggested answers from the mailing list:

> http://stackoverflow.com/questions/10529351/using-a-psycopg2-converter-to-retrieve-bytea-data-from-postgresql
>

With thanks,
Andy

On 11/05/2012, at 7:43 AM, Daniele Varrazzo wrote:

>
> On May 10, 2012 11:18 PM, "Andy Casey" <andycasey(at)gmail(dot)com> wrote:
> >
> > Hi there,
> >
> > I have used psycopg2's adapters and converters in the past with numeric[] arrays in PostgreSQL, and now I'm trying to use them with binary data types (bytea). I've outlined my problem in detail with some test code which illustrates what works (without adapters/converters), and how it fails when I build my working code into using an adapter and converter:
> >
> > http://stackoverflow.com/questions/10529351/using-a-psycopg2-converter-to-retrieve-bytea-data-from-postgresql
> >
> > Would you mind taking a look and providing some advice?
> >
> > Thanks,
> > Andy
>
> As answered on SO:
>
> """
> The format you see in the debugger is easy to parse: it is PostgreSQL hex binary format (http://www.postgresql.org/docs/9.1/static/datatype-binary.html). psycopg can parse that format and return a buffer containing the data; you can use that buffer to obtain an array. Instead of writing a typecaster from scratch, write one invoking the original func and postprocess its result. Sorry but I can't remember its name now and I'm writing from a mobile: you may get further help from the mailing list.
> """
>
> I think you are close to the solution of your case: please keep us informed!
>
> -- Daniele
>

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2012-05-21 08:22:56 Re: Using a psycopg2 converter to retrieve bytea data from PostgreSQL
Previous Message Federico Di Gregorio 2012-05-18 13:18:09 Re: reset implementation