This project is archived and is in readonly mode.

#114 ✓resolved
Psycopg website

hstore adapter

Reported by Psycopg website | June 27th, 2012 @ 04:42 PM

Submitted by: Adrian Klaver

Seems the register_hstore only works with connections that use cursors that return an indexed tuple. When using the RealDictConnection/Cursor I get the traceback below. It can be worked around by supplying the OID.

/home/aklaver/<ipython-input-12-b3da0e399c73> in <module>()
----> 1 psycopg2.extras.register_hstore(cur)

/usr/local/lib/python2.6/dist-packages/psycopg2-2.4.3-py2.6-linux-i686.egg/
psycopg2/extras.pyc in register_hstore(conn_or_curs, globally, unicode, oid,
array_oid)
    742     """
    743     if oid is None:
--> 744         oid = HstoreAdapter.get_oids(conn_or_curs)
    745         if oid is None or not oid[0]:
    746             raise psycopg2.ProgrammingError(

/usr/local/lib/python2.6/dist-packages/psycopg2-2.4.3-py2.6-linux-i686.egg/
psycopg2/extras.pyc in get_oids(self, conn_or_curs)
    690 """ % typarray)
    691         for oids in curs:
--> 692             rv0.append(oids[0])
    693             rv1.append(oids[1])
    694

Comments and changes to this ticket

  • Daniele Varrazzo

    Daniele Varrazzo June 27th, 2012 @ 05:35 PM

    • State changed from “new” to “open”

    Yes, several psycopg parts don't work correctly with RealDict cursors, because they are not dbapi-compatible. Supplying the OID is the designed workaround.

    OTOH, one of the changes recently committed in devel allows any non-base connection to create cursor of different classes: I think it should be easy to make these cursor internal usage more robust specifying the base cursor as cursor_factory.

  • Adrian Klaver

    Adrian Klaver June 27th, 2012 @ 08:09 PM

    In the meantime would it be possible to change the documentation to make this plain.

  • Daniele Varrazzo

    Daniele Varrazzo August 14th, 2012 @ 10:30 PM

    • State changed from “open” to “resolved”

    Fixed in my devel. Thank you for the report.

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

Tags

Referenced by

Pages