Re: flexi adaption/casting scheme

From: Tobias Oberstein <tobias(dot)oberstein(at)gmail(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: flexi adaption/casting scheme
Date: 2012-09-22 18:57:23
Message-ID: 505E0A13.6090605@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Am 22.09.2012 20:42, schrieb Daniele Varrazzo:
> On Sat, Sep 22, 2012 at 7:02 PM, Tobias Oberstein
> <tobias(dot)oberstein(at)gmail(dot)com> wrote:
>>> Procedures with OUT parameters don't return a specific oid: they
>>> return a generic "record" oid (2249).
>>
>>
>> Sorry to bother you once more: is it possible to cast any PG RECORD
>> (anything OID 2249) into Python _lists_?
>
> Postgres doesn't tell you the oids of the components, so you cannot
> cast them to python types: you can only have them as strings.
>
> -- Daniele
>

Ok;( Thinking more about it, I now can see how the PG SQL "wire format"
just isn't self-describing, and that records are really anonymous
composite types.

Anyway, and FWIW, I've implemented a RecordCaster that does like you say
(parses RECORDs into Python lists of strings):

https://github.com/oberstet/scratchbox/blob/master/python/psycopg2/test9.py

Tokenizer code is stolen from your CompositeCaster;)

The stuff is of course of limited use .. all elements get cast to string.

The consequence is, that I probably need to require users of the
JSON-RPC to PG stored procedure stuff to have their (remoted) SPs
without OUT or INOUT parameters and without RECORD types. And probably
without VARIADIC also. Ok, having only 1 OUT works, but then one can use
RETURN just as well.

Thanks!

Tobias

In response to

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2012-09-24 08:56:14 Range type adaptation implemented
Previous Message Daniele Varrazzo 2012-09-22 18:42:27 Re: flexi adaption/casting scheme