【发布时间】:2018-07-02 03:35:26
【问题描述】:
我有一个使用 BigQuery 节点运行的 Node-RED 安装,但它突然停止工作。已经能够将其缩小到一个我无法再工作的非常小的示例:
代码如下所示:
// Imports the Google Cloud client library
const BigQuery = require('@google-cloud/bigquery');
// Your Google Cloud Platform project ID
const projectId = 'my-project';
const file = './google-cloud-auth.json'
// Creates a client
const bigquery = new BigQuery({
projectId: projectId,
keyFilename: file
});
const datainsert = {
"water_total": 555,
"power_vp": 3460651,
"power_ftx": 4401819,
"time": "2018-01-23T09:50:17.672Z",
"power_total": 5737457,
"power_garage_radiator_south": 182521,
"power_garage_radiator_north": 76388
};
// The name for the new dataset
const dataset = bigquery.dataset('consumption');
const table = dataset.table('consumption_test');
table.insert(datainsert, function(err, response) {
console.log(JSON.stringify(err));
console.log(JSON.stringify(response));
});
当我在我的 Ubuntu 机器(NodeJS v4.8.7)上运行它时,它会输出:
{}
undefined
没有任何东西被写入 BQ。 但是,当我在我的 Mac(NodeJS v6.9.4)上运行完全相同的代码(实际上我试图复制整个文件夹结构)时,它会输出:
null
{"kind":"bigquery#tableDataInsertAllResponse"}
记录保存成功。
显然我认为它与 Node 版本有关,所以我尝试在它曾经运行但使用 NodeJS v6.9.4 的 Docker 容器中运行它,但它仍然无法在该机器上成功运行。我正在使用相同的身份验证文件运行,所以我认为它与此无关。
有没有人碰巧知道我的环境中是什么导致了这种情况发生?
【问题讨论】:
标签: node.js google-bigquery google-cloud-platform