def chunk_list(lst, n) -> list: for i in range(0, len(lst), n): yield lst[i:i + n] def compile_query_to_plain_sql(query) -> str: return query.compile(compile_kwargs={ 'literal_binds': True }) def to_locale_number(value): return '{:,}'.format(value).replace(',', ' ')