-
Notifications
You must be signed in to change notification settings - Fork 32
/
logging.js
37 lines (31 loc) · 1.02 KB
/
logging.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// Two types of logging are available.
//
// * SDK logging messages are emitted by the Snowflake SDK. These can be turned on by
// setting logLevel to the desired level (such as 'trace').
//
// * You can log SQL queries. This is enabled by passing a _function_ that will receive
// a string to be logged. The string includes the database and schema name, the sqlText,
// and the (local) elapsed time.
//
const Snowflake = require('snowflake-promise').Snowflake;
async function main() {
const snowflake = new Snowflake({
account: '<account name>',
username: '<username>',
password: '<password>',
database: 'SNOWFLAKE_SAMPLE_DATA',
schema: 'TPCH_SF1',
warehouse: 'DEMO_WH'
}, {
logLevel: 'trace', // maximum SDK logLevel
logSql: console.log // SQL statements will be logged to the console
});
await snowflake.connect();
const rows = await snowflake.execute(
'SELECT COUNT(*) FROM CUSTOMER WHERE C_MKTSEGMENT=:1',
['AUTOMOBILE']
);
console.log(rows);
}
main();