This project is archived and is in readonly mode.
Error in register_composite python 3
Reported by Joshua Boshi | August 14th, 2012 @ 11:33 AM
I am running psycopg2 2.4.5 on python 3.2.2.
I found error in psycopg2.extras.register_composite which is probably caused because of usage of old formatting of SQL query string with percent sign. When I updated this code to use string's format method, everything worked properly.
Comments and changes to this ticket
register_composite works for me.
psql (9.0.3, server 9.0.5) Type "help" for help. piro=> create type foo as (a integer, b integer); CREATE TYPE piro=> create table bar (b integer, c integer); CREATE TABLE
piro@bagheera:~/dev/psycopg2/build/lib.3.2$ python3.2 Python 3.2.2 (default, Sep 5 2011, 22:09:30) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg2 >>> cnn = psycopg2.connect('') >>> cur = cnn.cursor() >>> import psycopg2.extras >>> psycopg2.extras.register_composite('foo', cnn) <psycopg2.extras.CompositeCaster object at 0x86d4f0c> >>> cur.execute('select (10,20)::foo') >>> cur.fetchone() (foo(a=10, b=20),) >>> psycopg2.extras.register_composite('bar', cur) <psycopg2.extras.CompositeCaster object at 0x879b12c> >>> cur.execute('select (30,40)::bar') >>> cur.fetchone() (bar(b=30, c=40),)
Please check you are doing everything right. If so, please post a reproducible test case.
- State changed from new to hold
Joshua, no answer? I'm putting the ticket on hold as it works for me and I suspect you just didn't install psycopg correctly. If you can still reproduce the bug feel free to re-open it but provide a failing script. Thank you.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
WARNING: the informations in this tracker are archived. Please submit new tickets or comments to the new tracker.
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.