t.f.t.QueryIterator : class documentation

Part of twisted.flow.threads View Source View In Hierarchy

Converts a database query into a result iterator

Example usage:
   from __future__         import generators
   from twisted.enterprise import adbapi
   from twisted.internet   import reactor
   from twisted.flow import flow
   from twisted.flow.threads import QueryIterator, Threaded

   dbpool = adbapi.ConnectionPool("SomeDriver",host='localhost',
                db='Database',user='User',passwd='Password')

   # # I test with...
   # from pyPgSQL import PgSQL
   # dbpool = PgSQL

   sql = '''
     (SELECT 'one')
   UNION ALL
     (SELECT 'two')
   UNION ALL
     (SELECT 'three')
   '''
   def consumer():
       print "executing"
       query = Threaded(QueryIterator(dbpool, sql))
       print "yielding"
       yield query
       print "done yeilding"
       for row in query:
           print "Processed result : ", row
           yield query

   from twisted.internet import reactor
   def finish(result):
       print "Deferred Complete : ", result
       reactor.stop()
   f = flow.Deferred(consumer())
   f.addBoth(finish)
   reactor.run()
Method __init__ Undocumented
Method __iter__ Undocumented
Method next_fetchall Undocumented
Method next_fetchmany Undocumented
Method next Undocumented
def __init__(self, pool, sql, fetchmany=False, fetchall=False): (source)
Undocumented
def __iter__(self): (source)
Undocumented
def next_fetchall(self): (source)
Undocumented
def next_fetchmany(self): (source)
Undocumented
def next(self): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.