def create_df_file_with_query(self, query, output):
    ' Dumps in df in chunks to avoid crashes.\n        '
    chunk_size = 100000
    offset = 0
    data = defaultdict((lambda : defaultdict(list)))
    with open(output, 'wb') as outfile:
        query = query.replace(';', '')
        query += ' LIMIT {chunk_size} OFFSET {offset};'
        while True:
            print(offset)
            query = query.format(chunk_size=chunk_size, offset=offset)
            df = pd.read_sql(query, self.engine)
            pickle.dump(df, outfile)
            offset += chunk_size
            if (len(df) < chunk_size):
                break
        outfile.close()
Dumps in df in chunks to avoid crashes.
def create_df_file_with_query(self, query, output):
    ' \n        '
    chunk_size = 100000
    offset = 0
    data = defaultdict((lambda : defaultdict(list)))
    with open(output, 'wb') as outfile:
        query = query.replace(';', )
        query += ' LIMIT {chunk_size} OFFSET {offset};'
        while True:
            print(offset)
            query = query.format(chunk_size=chunk_size, offset=offset)
            df = pd.read_sql(query, self.engine)
            pickle.dump(df, outfile)
            offset += chunk_size
            if (len(df) < chunk_size):
                break
        outfile.close()