def _write_local_schema_file(self, cursor):
    '\n        Takes a cursor, and writes the BigQuery schema for the results to a\n        local file system.\n\n        :return: A dictionary where key is a filename to be used as an object\n            name in GCS, and values are file handles to local files that\n            contains the BigQuery schema fields in .json format.\n        '
    schema = [self.field_to_bigquery(field) for field in cursor.description]
    self.log.info('Using schema for %s: %s', self.schema_filename, schema)
    tmp_schema_file_handle = NamedTemporaryFile(delete=True)
    tmp_schema_file_handle.write(json.dumps(schema, sort_keys=True).encode('utf-8'))
    schema_file_to_upload = {'file_name': self.schema_filename, 'file_handle': tmp_schema_file_handle, 'file_mime_type': 'application/json'}
    return schema_file_to_upload
Takes a cursor, and writes the BigQuery schema for the results to a
local file system.

:return: A dictionary where key is a filename to be used as an object
    name in GCS, and values are file handles to local files that
    contains the BigQuery schema fields in .json format.
def _write_local_schema_file(self, cursor):
    '\n        Takes a cursor, and writes the BigQuery schema for the results to a\n        local file system.\n\n        :return: A dictionary where key is a filename to be used as an object\n            name in GCS, and values are file handles to local files that\n            contains the BigQuery schema fields in .json format.\n        '
    schema = [self.field_to_bigquery(field) for field in cursor.description]
    self.log.info('Using schema for %s: %s', self.schema_filename, schema)
    tmp_schema_file_handle = NamedTemporaryFile(delete=True)
    tmp_schema_file_handle.write(json.dumps(schema, sort_keys=True).encode('utf-8'))
    schema_file_to_upload = {'file_name': self.schema_filename, 'file_handle': tmp_schema_file_handle, 'file_mime_type': 'application/json'}
    return schema_file_to_upload