summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/extras.py17
-rw-r--r--psycopg/connection_type.c2
3 files changed, 16 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8756906..8f75da7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-20 Federico Di Gregorio <fog@debian.org>
+
+ * psycopg/connection_type.c (psyco_conn_cursor): renamed 'cursor'
+ argument to 'cursor_factory'.
+
2004-11-19 Federico Di Gregorio <fog@debian.org>
* psycopg/cursor_type.c (_psyco_curs_buildrow_fill): now standard
diff --git a/lib/extras.py b/lib/extras.py
index b9532f9..39f9caa 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -20,30 +20,34 @@ class DictCursor(_cursor):
__query_executed = 0
def execute(self, query, vars=None, async=0):
- self.tuple_factory = DictRow
+ self.row_factory = DictRow
self.index = {}
self.__query_executed = 1
return _cursor.execute(self, query, vars, async)
def _build_index(self):
- if self.description:
+ if self.__query_executed == 1 and self.description:
for i in range(len(self.description)):
self.index[self.description[i][0]] = i
-
+ self.__query_executed = 0
+
def fetchone(self):
+ res = _cursor.fetchone(self)
if self.__query_executed:
self._build_index()
- return _cursor.fetchone(self)
+ return res
def fetchmany(self, size=None):
+ res = _cursor.fetchmany(self, size)
if self.__query_executed:
self._build_index()
- return _cursor.fetchmany(self, size)
+ return res
def fetchall(self):
+ res = _cursor.fetchall(self)
if self.__query_executed:
self._build_index()
- return _cursor.fetchall(self)
+ return res
class DictRow(list):
"""A row object that allow by-colun-name access to data."""
@@ -51,7 +55,6 @@ class DictRow(list):
def __init__(self, cursor):
self._cursor = cursor
self[:] = [None] * len(cursor.description)
- print cursor, self
def __getitem__(self, x):
if type(x) != int:
diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c
index 376b7e6..1d544f6 100644
--- a/psycopg/connection_type.c
+++ b/psycopg/connection_type.c
@@ -48,7 +48,7 @@ psyco_conn_cursor(connectionObject *self, PyObject *args, PyObject *keywds)
char *name = NULL;
PyObject *obj, *factory = NULL;
- static char *kwlist[] = {"name", "factory", NULL};
+ static char *kwlist[] = {"name", "cursor_factory", NULL};
if (!PyArg_ParseTupleAndKeywords(args, keywds, "|sO", kwlist,
&name, &factory)) {