Issue: googleapis/nodejs-bigquery#361
- Set the path to your key file in
.env
$ node ./
GOOGLE_APPLICATION_CREDENTIALS=/Users/stephen/dev/key.json |
Issue: googleapis/nodejs-bigquery#361
.env
$ node ./
{ "name": "name1" } | |
{ "name": "name2" } | |
{ "name": "name3" } |
'use strict' | |
require('dotenv').config() | |
const {BigQuery} = require('@google-cloud/bigquery') | |
const bigquery = new BigQuery() | |
const dataset = bigquery.dataset(`dataset_${Date.now()}`) | |
const table = dataset.table('names') | |
dataset.create() | |
.then(() => table.create({schema:'name:string'})) | |
.then(() => table.createLoadJob('./data.csv')) | |
.then(([job]) => new Promise((y, n) => job.on('error', n).on('complete', y))) | |
.then(() => table.query('SELECT * FROM `names`')) | |
.then(([rows]) => console.log(`${rows.length === 3 ? 'Yay!' : 'No :('}`)) | |
.then(() => dataset.delete({force:true}), () => dataset.delete({force:true})) |
{ | |
"name": "gissue-361", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@google-cloud/bigquery": "^2.0.6", | |
"dotenv": "^6.2.0" | |
} | |
} |