def _result_iter(cursor, arraysize):
    """
    An iterator that uses fetchmany to keep memory usage down
    """
    count = 0
    while True:
        results = cursor.fetchmany(arraysize)
        count += len(results)
        if not results:
            print('no rows to process')
            break
        print('%s rows processed' % count)
        for result in results:
            yield result
