[Zope-DB] CVS: Products/DCOracle2/DCOracle2 - DCOracle2.py:1.74
Matthew T. Kromer
matt@zope.com
Wed, 10 Oct 2001 14:11:49 -0400
Update of /cvs-repository/Products/DCOracle2/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv27145/DCOracle2
Modified Files:
DCOracle2.py
Log Message:
Updated Changelog.
Added skip= parameters to cursor fetchone, fetchmany, and fetchall to
enable discarding of answers before converting them into python objects
(not a DB 2.0 API compliant change -- shoot me).
=== Products/DCOracle2/DCOracle2/DCOracle2.py 1.73 => 1.74 ===
return result
- def fetchone(self):
+ def fetchone(self,skip=0):
if self._cursor is None:
raise InterfaceError,"cursor is closed"
if self._result is not None and self._rcount >= len(self._result[0]):
@@ -940,9 +940,20 @@
l = []
- for i in self._result:
+ if skip > 0:
+ while skip:
+ advance = skip
+ setremain = len(self._result[0]) - self._rcount
+ if advance > setremain: advance = setremain
+ self._rcount = self._rcount + advance
+ skip = skip - advance
+ if self._rcount >= len(self._result[0]):
+ self._result = self._cursor.fetch(self.arraysize)
+ self._rcount = 0
+
+ for col in self._result: # Result set is column based
try:
- v = i[self._rcount].value()
+ v = col[self._rcount].value()
except IndexError:
self._result = None
return None
@@ -960,7 +971,7 @@
return l
- def fetchmany(self, size=arraysize):
+ def fetchmany(self, size=arraysize, skip=0):
if self._cursor is None:
raise InterfaceError,"cursor is closed"
a = []
@@ -969,23 +980,25 @@
# default query as 999999
i = 0
while i < size:
- v = self.fetchone()
+ v = self.fetchone(skip=skip)
if v is None: break
a.append(v)
i= i+1
+ skip = 0
self.rowcount = self._cursor.rowcount()
return a
- def fetchall(self):
+ def fetchall(self, skip=0):
if self._cursor is None:
raise InterfaceError,"cursor is closed"
a = []
while 1:
- v = self.fetchone()
+ v = self.fetchone(skip=skip)
if v is None: break
a.append(v)
+ skip = 0
self.rowcount = self._cursor.rowcount()
return a