Google bigquery BigQuery+;javascript(tabledata.insertAll)
这是我的密码:Google bigquery BigQuery+;javascript(tabledata.insertAll),google-bigquery,Google Bigquery,这是我的密码: function runQuery(){ var json = JSON.stringify({"string": "eight", "number": "8", "id": "8"}); var body = { "kind": "bigquery#tableDataInsertAllRequest", "rows": [ { "insertId": "8",
function runQuery(){
var json = JSON.stringify({"string": "eight", "number": "8", "id": "8"});
var body = {
"kind": "bigquery#tableDataInsertAllRequest",
"rows": [
{
"insertId": "8",
"json": json
}
]
};
var request = gapi.client.bigquery.tabledata.insertAll({
'projectId': project_id,
'datasetId': 'newTest',
'tableId': 'newTable',
'content': body
});
request.execute(function(response){
console.log(response);
});
}
但此代码返回错误:表数据追加请求中不存在记录。(400)有人能帮我吗?问题已解决:
var request = gapi.client.bigquery.tabledata.insertAll({
'projectId': projectId,
'datasetId': datasetId,
'tableId': tableId,
"kind": "bigquery#tableDataInsertAllRequest",
"rows":[
{
"insertId": "10",
"json": {"id": "10", "string": "ten", "number": "10"}
}
]
});
无法将数据附加到示例数据集。创建自己的以执行插入。在同一问题上花费了大量时间。 dbepcepk的回答导致了以下错误: 错误:接收到无效的JSON负载。未知名称“rows”:无法绑定查询参数。“rows”是消息类型。参数只能绑定到基元类型 以下是我如何绕过它的: 注意定义TableDataInsertAllRequest对象的JSON键“resource”
const request ={
"projectId": projectId,
"datasetId": datasetId,
"tableId": tableId,
"resource":{
"kind": "bigquery#tableDataInsertAllRequest",
"skipInvalidRows": false,
"ignoreUnknownValues": false,
"templateSuffix":"",
"rows": [{"json": {"test":true}]
}
}
client.tabledata.insertAll(
request,
(err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
回答得好,如果你能更具体一点就更好了。尽可能使用链接和示例。=)谢谢@JackDev,下次我会这么做的!跟踪github链接导致404错误。