Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 19. Iterators and Generators > Fetching Large Record Sets from a Databa...

Recipe 19.13. Fetching Large Record Sets from a Database with a Generator

Credit: Christopher Prinos

19.14.1. Problem

You want to fetch a result set from a database (using the Python DB API) and easily iterate over each record in the result set. However, you don't want to use the DB cursor's method fetchall: it could consume a lot of memory and would force you to wait until the whole result set comes back before you can start iterating.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial