This project is archived and is in readonly mode.
KeyError on psycopg2.extras.register_hstore()
-
Daniele Varrazzo
- State changed from new to hold
As it says on the tin, RealDictCursor is "extremely specialized and does not allow the normal access (using integer indices) to fetched data". It basically violates the DBAPI interface. For this reason I'm against fixing it: register_hstore() (but also register_composite() and probably tpc_recover() too) just assumes the cursor is DBAPI-valid, and accepting the possibility it isn't just makes a mess. For example, if you pass a cursor to register_hstore(), it can't be used for querying, but its connection must be obtained and a plain cursor built out of it - and I'm not even sure cursor_factory is honoured by all the connection subclasses.
There are other ways to register hstore and use it from a RealDictCursor: use a regular cursor and register it on the connection, or use a regular connection and register it globally, or use a regular connection to get the hstore oid and register it without the internal query, as explained in the docs.
-
Daniele Varrazzo
- State changed from hold to resolved
This issue was fixed in my devel. To be released in 2.4.6.
Duplicate of issue #114 hstore adapter.
-
Samuel PHAN
Cool, congratz Daniele ! ;-)