Convert cursor.fetch into a generator