def windowed_query(q, column, windowsize):
    """"Break a Query into windows on a given column."""

    for whereclause in column_windows(q.session, column, windowsize):
        yield from q.filter(whereclause).order_by(column)
"Break a Query into windows on a given column.
lemur/common/utils.py