def InsertData(self, table_id, fd, schema, job_id):
    configuration = {
        "schema": {"fields": schema},
        "destinationTable": {
            "projectId": self.project_id,
            "tableId": table_id,
            "datasetId": self.dataset_id
        },
        "sourceFormat": "NEWLINE_DELIMITED_JSON",
    }

    body = {
        "configuration": {
            "load": configuration
        },
        "jobReference": {
            "projectId": self.project_id,
            "jobId": job_id
        }
    }

    # File content can be gzipped for bandwidth efficiency. The server handles
    # it correctly without any changes to the request.
    mediafile = MediaFileUpload(fd.name, mimetype="application/octet-stream")
    job = self.service.jobs().insert(projectId=self.project_id, body=body,
                                     media_body=mediafile)
    try:
      response = job.execute()
      return response
    except HttpError as e:
      if self.GetDataset(self.dataset_id):
        logging.exception("Error with job: %s", job_id)
      else:
        # If this is our first export ever, we need to create the dataset.
        logging.info("Attempting to create dataset: %s", self.dataset_id)
        self.CreateDataset()
      return self.RetryUpload(job, job_id, e)
Insert data into a bigquery table.
dataset/ETHPy150Open google/grr/grr/lib/bigquery.py/BigQueryClient.InsertData