This project is archived and is in readonly mode.

#118 ✓invalid
Joshua Boshi

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.

Best regards,
Joshua

Comments and changes to this ticket

  • Daniele Varrazzo

    Daniele Varrazzo August 14th, 2012 @ 08:59 PM

    Hello Joshua,

    register_composite works for me.

    In psql:

    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
    

    In Python:

    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.

    Thank you.

  • Daniele Varrazzo

    Daniele Varrazzo September 18th, 2012 @ 10:57 AM

    • 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.

  • Joshua Boshi

    Joshua Boshi September 28th, 2012 @ 09:05 PM

    Hello Daniele,

    I am sorry. I have no time to provide you failing script. I am very busy.
    I will send it here when I have some free time.

    Best regards,
    Joshua

  • Daniele Varrazzo

    Daniele Varrazzo May 6th, 2013 @ 09:26 AM

    • State changed from “hold” to “invalid”

    Joshua can't be bothered. Never do us. The bug is probably caused by incorrect python3 installation as there's plenty of register_composite tests in the test suite.

Create your profile

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

<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
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

Pages