def _write_local_data_files(self, cursor):
    '\n        Takes a cursor, and writes results to a local file.\n\n        :return: A dictionary where keys are filenames to be used as object\n            names in GCS, and values are file handles to local files that\n            contain the data for the GCS objects.\n        '
    schema = list(map((lambda schema_tuple: schema_tuple[0]), cursor.description))
    col_type_dict = self._get_col_type_dict()
    file_no = 0
    tmp_file_handle = NamedTemporaryFile(delete=True)
    if (self.export_format == 'csv'):
        file_mime_type = 'text/csv'
    else:
        file_mime_type = 'application/json'
    files_to_upload = [{'file_name': self.filename.format(file_no), 'file_handle': tmp_file_handle, 'file_mime_type': file_mime_type}]
    if (self.export_format == 'csv'):
        csv_writer = self._configure_csv_file(tmp_file_handle, schema)
    for row in cursor:
        row = self.convert_types(schema, col_type_dict, row)
        if (self.export_format == 'csv'):
            csv_writer.writerow(row)
        else:
            row_dict = dict(zip(schema, row))
            tmp_file_handle.write(json.dumps(row_dict, sort_keys=True).encode('utf-8'))
            tmp_file_handle.write(b'\n')
        if (tmp_file_handle.tell() >= self.approx_max_file_size_bytes):
            file_no += 1
            tmp_file_handle = NamedTemporaryFile(delete=True)
            files_to_upload.append({'file_name': self.filename.format(file_no), 'file_handle': tmp_file_handle, 'file_mime_type': file_mime_type})
            if (self.export_format == 'csv'):
                csv_writer = self._configure_csv_file(tmp_file_handle, schema)
    return files_to_upload
Takes a cursor, and writes results to a local file.

:return: A dictionary where keys are filenames to be used as object
    names in GCS, and values are file handles to local files that
    contain the data for the GCS objects.
def _write_local_data_files(self, cursor):
    '\n        Takes a cursor, and writes results to a local file.\n\n        :return: A dictionary where keys are filenames to be used as object\n            names in GCS, and values are file handles to local files that\n            contain the data for the GCS objects.\n        '
    schema = list(map((lambda schema_tuple: schema_tuple[0]), cursor.description))
    col_type_dict = self._get_col_type_dict()
    file_no = 0
    tmp_file_handle = NamedTemporaryFile(delete=True)
    if (self.export_format == 'csv'):
        file_mime_type = 'text/csv'
    else:
        file_mime_type = 'application/json'
    files_to_upload = [{'file_name': self.filename.format(file_no), 'file_handle': tmp_file_handle, 'file_mime_type': file_mime_type}]
    if (self.export_format == 'csv'):
        csv_writer = self._configure_csv_file(tmp_file_handle, schema)
    for row in cursor:
        row = self.convert_types(schema, col_type_dict, row)
        if (self.export_format == 'csv'):
            csv_writer.writerow(row)
        else:
            row_dict = dict(zip(schema, row))
            tmp_file_handle.write(json.dumps(row_dict, sort_keys=True).encode('utf-8'))
            tmp_file_handle.write(b'\n')
        if (tmp_file_handle.tell() >= self.approx_max_file_size_bytes):
            file_no += 1
            tmp_file_handle = NamedTemporaryFile(delete=True)
            files_to_upload.append({'file_name': self.filename.format(file_no), 'file_handle': tmp_file_handle, 'file_mime_type': file_mime_type})
            if (self.export_format == 'csv'):
                csv_writer = self._configure_csv_file(tmp_file_handle, schema)
    return files_to_upload