I'd like to make a generic 'to array' type caster for any types not
natively recognised by psycopg2. Specifically, not only do I want to
convert types such as json and uuid, but it would be useful to have
varchar arrays for any unrecognised types (I appreciate uuids are now a
recognised type since 2.0.9).
I've looked at
http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.new_array_type
and the following code:
psycopg2.extensions.register_type(
psycopg2.extensions.new_array_type(
(1040,), 'MACADDR[]', psycopg2.STRING))
I'm worried about the following:
- avoiding providing oids of all types we don't know about, since it might be
different in every database we connect to
- how to learn the oids of array types already handled by psycopg2
Rory
--
Rory Campbell-Lange
rory@campbell-lange.net