getting Gadfly data into a list

Sean 'Shaleh' Perry shaleh at valinux.com
Tue Apr 24 13:20:49 EDT 2001


On 24-Apr-2001 Lee Joramo wrote:
> I have set up a small database using gadfly. Is there a way to directly pull
> query results into a list? Currently the only way that I have found to
> access the data is by using "cursor.pp()". But this displays a nicely
> formatted table that is difficult to use for anything.
> 

a lesson I have learned is to look at the python source code.  Often the
answers are there waiting for you.

class GF_Cursor:
  <snip>
     def fetchmany(self, size=None):
       if self.verbose:
           print "GF_Cursor.fetchmany", id(self)
       r = self.resultlist
       if r is None:
           self.reset_results()
           r = self.resultlist
       if size is None:
           size = len(r)
       result = r[:size]
       del r[:size]
       return result
       
     def fetchall(self):
       if self.verbose:
           print "GF_Cursor.fetchall", id(self)
       return self.fetchmany()

so try cursor.fetchall().




More information about the Python-list mailing list