Skip to content

Instantly share code, notes, and snippets.

@rominirani
Last active February 4, 2018 09:43
Show Gist options
  • Save rominirani/5c39fb5d09a47d9933e937b77eb81366 to your computer and use it in GitHub Desktop.
Save rominirani/5c39fb5d09a47d9933e937b77eb81366 to your computer and use it in GitHub Desktop.
const bigquery = require('@google-cloud/bigquery')({
projectId: 'your-project-id',
keyFilename: 'key.json'
});
const sqlQuery = "SELECT total_amount, pickup_datetime, trip_distance FROM 'nyc-tlc.yellow.trips' ORDER BY total_amount DESC LIMIT 1;";
const options = {
query: sqlQuery,
timeoutMs: 10000,
useLegacySql: false,
};
bigquery
.query(options)
.then(results => {
const rows = results[0];
console.log('Rows:');
rows.forEach(row => console.log(row));
})
.catch(err => {
console.error('ERROR:', err);
});`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment