#66 ✓ resolved
Sergey Shepelev

Array of composite/hstore type

Reported by Sergey Shepelev | August 15th, 2011 @ 03:05 PM

db=> create type comp_type_test as (id uuid, f1 char(2), f2 smallint, f3 char(3), f4 char(3));

>>> psycopg2.extras.register_composite('comp_type_test', connection, globally=True)

>>> db.execute("select ('000003b3-50a9-eeaa-4aab-2a95e6ca6592', 'J2', 600, 'MOW', 'BER')::comp_type_test").fetchone()
(comp_type_test(id=UUID('000003b3-50a9-eeaa-4aab-2a95e6ca6592'), f1=u'J2', f2=600, f3=u'MOW', f4=u'BER'),)

This is good.

>>> db.execute("select array[('000003b3-50a9-eeaa-4aab-2a95e6ca6592', 'J2', 600, 'MOW', 'BER')]::comp_type_test[]").fetchone()
('{"(000003b3-50a9-eeaa-4aab-2a95e6ca6592,J2,600,MOW,BER)"}',)

This is not good.

Is it possible to make psycopg2 understand arrays of composite values (or at least arrays of hstore)?

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.

Shared Ticket Bins

Tags

Pages