From 5ea2fa636fa43eecf8d5d8f2d4b826f077fc1bcb Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Tue, 6 Dec 2005 05:55:58 +0000 Subject: [PATCH] Better DictCursor. --- ChangeLog | 5 +++++ LICENSE | 8 ++++++++ lib/extras.py | 6 ++++++ psycopg/cursor_type.c | 2 +- psycopg/pqpath.c | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 20a66ceb..2af437b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-12-06 Federico Di Gregorio + + * lib/extras.py: added .callproc() to DictCursor as suggested + by Philip Semanchuk. + 2005-11-29 Federico Di Gregorio * MANIFEST.in: added docs/async.txt. (Closes: #75) diff --git a/LICENSE b/LICENSE index 46ba5fe2..381fdd96 100644 --- a/LICENSE +++ b/LICENSE @@ -50,3 +50,11 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +Proprietary licenses +==================== + +A non-discriminatory license is available for companies that want to include +psycopg in their proprietary products without respecting the spirit of the +GPL. The price of the license is one day of development done by the author, +at the consulting fee he applies to his usual customers at the day of the +request. diff --git a/lib/extras.py b/lib/extras.py index 39adf0cd..a69caa2f 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -37,6 +37,12 @@ class DictCursor(_cursor): self.index = {} self.__query_executed = 1 return _cursor.execute(self, query, vars, async) + + def callproc(self, procname, vars=None): + self.row_factory = DictRow + self.index = {} + self.__query_executed = 1 + return _cursor.callproc(self, procname, vars) def _build_index(self): if self.__query_executed == 1 and self.description: diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 6f84ca4e..2aadc78b 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -881,7 +881,7 @@ psyco_curs_callproc(cursorObject *self, PyObject *args, PyObject *kwargs) if (self->name != NULL) { PyErr_SetString(ProgrammingError, - "can't call .executemany() on named cursors"); + "can't call .callproc() on named cursors"); return NULL; } diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 111069f5..4ee87813 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -815,6 +815,7 @@ pq_fetch(cursorObject *curs) else #endif ex = _pq_copy_out(curs); + curs->rowcount = -1; /* error caught by out glorious notice handler */ if (PyErr_Occurred()) ex = -1; IFCLEARPGRES(curs->pgres); @@ -828,6 +829,7 @@ pq_fetch(cursorObject *curs) else #endif ex = _pq_copy_in(curs); + curs->rowcount = -1; /* error caught by out glorious notice handler */ if (PyErr_Occurred()) ex = -1; IFCLEARPGRES(curs->pgres);