Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Error in register_composite python 3

#118

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

Reported by Joshua Boshi · August 14th, 2012 @ 11:33 AM

State: invalid
Milestone: none
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo

    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.

    August 14th, 2012 @ 08:59 PM

  2. Daniele Varrazzo
    Daniele Varrazzo
    • 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.

    September 18th, 2012 @ 10:57 AM

  3. Joshua Boshi
    Joshua Boshi

    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

    September 28th, 2012 @ 09:05 PM

  4. Daniele Varrazzo
    Daniele Varrazzo
    • 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.

    May 6th, 2013 @ 09:26 AM