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 |