snowflake-promise/examples/oldSchool.js
2017-09-11 03:37:13 +00:00

41 lines
1016 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// This example shows how to use the library in traditional Promise style. You
// might do this if you are using an older version of Node that doesnt support
// async/await, or simply if you prefer the Promise/then syntax.
//
// (You could also transpile async/await code using TypeScript or Babel, which
// allows it to run on older versions of Node.)
//
// This library supports Node 4.0.0 and higher.
//
var Snowflake = require('snowflake-promise').Snowflake;
function main() {
var snowflake = new Snowflake({
account: '<account name>',
username: '<username>',
password: '<password>',
database: 'SNOWFLAKE_SAMPLE_DATA',
schema: 'TPCH_SF1',
warehouse: 'DEMO_WH'
});
snowflake.connect()
.then(function() {
return snowflake.execute(
'SELECT COUNT(*) FROM CUSTOMER WHERE C_MKTSEGMENT=:1',
['AUTOMOBILE']
);
})
.then(function(rows) {
console.log(rows);
})
.catch(function(err) {
console.error(err);
})
;
}
main();