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>) |
Список | psycopg |
On Fri, Jul 1, 2011 at 2:05 PM, Ronan Dunklau <ronan.dunklau@kozea.fr> 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 по дате отправления: