def _fetch(self, limit=None): """Fetch rows from the current recordset. limit -- Number of rows to fetch, or None (default) to fetch all rows. """ if self.connection is None or self.rs is None: self._raiseCursorError( api.FetchFailedError, 'fetch() on closed connection or empty query set') return if self.rs.State == adc.adStateClosed or self.rs.BOF or self.rs.EOF: return list() if limit: # limit number of rows retrieved ado_results = self.rs.GetRows(limit) else: # get all rows ado_results = self.rs.GetRows() if self.recordset_format == api.RS_ARRAY: # result of GetRows is a two-dimension array length = len(ado_results ) // self.numberOfColumns # length of first dimension else: #pywin32 length = len( ado_results[0]) #result of GetRows is tuples in a tuple fetchObject = api.SQLrows( ado_results, length, self) # new object to hold the results of the fetch return fetchObject
def fetchall(self): try: self.rs = self.proxy.crsr_fetchall(self.id) if not self.rs: return [] return api.SQLrows(self.rs, len(self.rs), self) except Exception, e: self._raiseCursorError(api.DatabaseError, e)
def fetchmany(self, size=None): try: self.rs = self.proxy.crsr_fetchmany(self.id, size) if not self.rs: return [] r = api.SQLrows(self.rs, len(self.rs), self) return r except Exception, e: self._raiseCursorError(api.DatabaseError, e)
if verbose > 2: print('%s callproc "%s" with params=%s' % (version, procname, repr(parameters))) return self.proxy.crsr_callproc(self.id, procname, fp) def fetchone(self): try: f1 = self.proxy.crsr_fetchone(self.id) except _BaseException, e: self._raiseCursorError(api.DatabaseError, e) else: if f1 is None: return None self.rs = [f1] return api.SQLrows( self.rs, 1, self)[0] # new object to hold the results of the fetch def fetchmany(self, size=None): try: self.rs = self.proxy.crsr_fetchmany(self.id, size) if not self.rs: return [] r = api.SQLrows(self.rs, len(self.rs), self) return r except Exception, e: self._raiseCursorError(api.DatabaseError, e) def fetchall(self): try: self.rs = self.proxy.crsr_fetchall(self.id)