【问题标题】:Can't upload any data to bigquery using table.insertall()无法使用 table.insertall() 将任何数据上传到 bigquery
【发布时间】:2016-09-01 09:05:19
【问题描述】:

这是我遇到问题的代码部分。

table_data_insert_all_request_body = {
    "kind": "bigquery#tableDataInsertAllRequest",
    "skipInvalidRows": True,
    "ignoreUnknownValues": True,
    "templateSuffix": 'suffix',
"rows": [
{
  "json": {
      ("one"): ("two"),
      ("three"): ("four")

          }
     }
    ]
}

request = service.tabledata().insertAll(projectId=projectId, datasetId=datasetId, tableId=tableId, body=table_data_insert_all_request_body)
response = request.execute()

如果我打印响应,我会得到响应:

{u'kind': u'bigquery#tableDataInsertAllResponse'}

我可以评估项目、数据集甚至表格,但我无法更新表格中的值。我需要做些什么不同的事情?显然我不想输入两个值,但我无法上传任何内容。一旦我可以上传一些东西,我就可以让行正常工作。

【问题讨论】:

  • 您能提供您的表架构吗?我觉得你这里给出的json数据格式不正确。

标签: python json python-2.7 google-bigquery


【解决方案1】:

即使不查看您的架构就很难判断,但我很确定您的 json 数据不正确。 这是我使用的。

Bodyfields = {
    "kind": "bigquery#tableDataInsertAllRequest",
    "rows": [
                {
                        "json": {
                            'col_name_1': 'row 1 value 1',
                            'col_name_2': 'row 1 value 2'
                        }
                },
                {
                        "json": {
                            'col_name_1': 'row 2 value 1',
                            'col_name_2': 'row 2 value 2'
                        }
                }
    ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-02
    • 1970-01-01
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    • 2021-02-16
    相关资源
    最近更新 更多