from sqlalchemy import MappingResult


class DBRowGenerator:
    """DBの検索結果を指定行数ごとに返すジェネレータ
    """
    FETCH_MANY_SIZE = 2000

    def __init__(self, mapping_result: MappingResult) -> None:
        self.mapping_result = mapping_result

    def __iter__(self):
        yield_per = self.mapping_result.yield_per(self.FETCH_MANY_SIZE)
        yield from yield_per
