Re: Custom array types converter

Поиск
Список
Период
Сортировка
Искать
От
Daniele Varrazzo
Тема
Re: Custom array types converter
Дата
Msg-id
BANLkTiny9CvOXAid0OP448PZ4oA=yj4Acw@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Custom array types converter Ronan Dunklau <ronan.dunklau@kozea.fr>
Re: Custom array types converter Daniele Varrazzo <daniele.varrazzo@gmail.com>
On Fri, Jul 1, 2011 at 2:05 PM, Ronan Dunklau  wrote:
> Hello.
>
> I'd like to register a type converter for _record (array of records).
>
> What is the "recommended" way to implement such a type ?

Psycopg doesn't play well with the generic record, as it has no type
information to parse the components. It can map user-defined types
though, as these informations are available in the catalog. However
there's currently no support for arrays of composite.

> I've seen that a "GENERIC_ARRAY" type caster is available in the c library,
> but I don't know how to access it from python.

I don't know the code in typecast_array.c very well, but if it can
tokenize the array string representation and delegate parsing of the
single items to another typecaster it should be easy to create the
missing array casters (composite array, hstore array...).

I think the code for the generic array casting is currently not
exposed to python. Probably a good extension could be to add an
optional array_oids parameter to the new_type() function in order to
register the arrays together with the base type
(http://initd.org/psycopg/docs/extensions.html#database-types-casting-functions).

-- Daniele
В списке psycopg по дате отправления
От: Ronan Dunklau
Дата:
Сообщение: Custom array types converter
От: deavid
Дата:
Сообщение: Named Cursors WITH HOLD
FAQ