Hi all!
As mentioned on the IRC channel before easter week, I've been taking a shot at the deprecate-psycopg1 blueprint (https://blueprints.launchpad.net/nav/+spec/deprecate-psycopg1)
Preliminary results can be found on this branch: http://metanav.uninett.no/hg/features/deprecate-psycopg1/
I would like to merge this code with the default branch as soon as possible. I would like it, though, if people who feel they have some sort of responsibility for code they've written would review the diffs.
A lot of code was using the dictfetchall, dictfetchone and dictfetchmany call on cursors. These are non-standard, and are no longer supported in psycopg2. To avoid making too many code changes related to this, I've opted to use a psycopg2 extension which allows me to use customized cursor classes.
The psycopg2 extensions already comes with a custom cursor class, which provides result rows that can be accessed both as tuples and dictionaries. To use the DictCursor class, I've had to manually specify the class as an argument to every call to connection.cursor(), where the code later expected to use the dictfetch methods on the cursor. All dictfetch calls have been reduced to regular fetch calls.
The custom cursor change affects the following subsystems:
* Arnold * deviceManagement * ipinfo * l2trace * lib-python (rrdPresenter) * maintenance * messages * Netmap * snmptrapd * statTools
See this changeset to see how I may have mauled your code: http://metanav.uninett.no/hg/features/deprecate-psycopg1/rev/4cbc70349d55
On another note: Does all this code _really_ need to use dictionary result rows? I don't know the internals of psycopg2's DictCursor, but I seems to me that it could be a real memory-waste to pull thousands of table rows as dictionary instances instead of simple tuples.
In many cases, I think looping over the results like this would suffice:
cursor.execute("SELECT column1, column2, column3 FROM foo") for (column1, column2, column3) in cursor.fetchall(): pass # or actually do something