Skip to content

Commit 5a4ca06

Browse files
committed
initial commit
0 parents  commit 5a4ca06

25 files changed

+2579
-0
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Editor config settings for foureyes-admin
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
tab_width = 2
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true

.gitignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# Project-specific ignores
61+
prod
62+
src/test.ts

.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# nyc test coverage report
2+
.nyc_output
3+
coverage
4+
5+
# editor settings
6+
.vscode
7+
.editorconfig
8+
9+
# unit tests
10+
test
11+
test/aws.json

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"eg2.tslint"
4+
]
5+
}

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to find out which attributes exist for node debugging
3+
// Use hover for the description of the existing attributes
4+
// For further information visit https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch Program",
9+
"type": "node",
10+
"request": "launch",
11+
"program": "${workspaceRoot}/src/app.ts",
12+
"cwd": "${workspaceRoot}",
13+
"outFiles": [ "${workspaceRoot}/prod/**/*.js" ],
14+
"sourceMaps": true,
15+
"preLaunchTask": "build"
16+
},
17+
{
18+
"name": "Launch test.ts",
19+
"type": "node",
20+
"request": "launch",
21+
"program": "${workspaceRoot}/src/test.ts",
22+
"cwd": "${workspaceRoot}",
23+
"outFiles": [ "${workspaceRoot}/prod/**/*.js" ],
24+
"sourceMaps": true,
25+
"preLaunchTask": "build"
26+
}
27+
]
28+
}

.vscode/settings.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Project-specific settings for Visual Studio Code
2+
{
3+
"editor.tabSize": 2,
4+
"editor.insertSpaces": true,
5+
"files.trimTrailingWhitespace": true,
6+
"files.insertFinalNewline": true,
7+
"files.exclude": {
8+
"**/prod": true,
9+
"**/node_modules": true,
10+
"**/coverage": true,
11+
"**/cache": true,
12+
"sessions.db": true
13+
},
14+
"tslint.autoFixOnSave": true,
15+
"typescript.tsdk": "./node_modules/typescript/lib",
16+
"search.useIgnoreFilesByDefault": true,
17+
"files.defaultLanguage": "typescript",
18+
"files.eol": "\n"
19+
}

.vscode/tasks.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "build",
8+
"type": "npm",
9+
"script": "build",
10+
"problemMatcher": [
11+
"$tsc"
12+
]
13+
}
14+
]
15+
}

LICENSE.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2017-present Nate Silva and other contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# snowflake-promise
2+
3+
A Promise-based interface to your [Snowflake](https://www.snowflake.net/) data warehouse.
4+
5+
This is a wrapper for the [Snowflake SDK](https://www.npmjs.com/package/snowflake-sdk) for Node.js. It provides a Promise-based API instead of the core callback-based API.
6+
7+
## Installation
8+
9+
`npm i snowflake-promise`
10+
11+
## Basic usage
12+
13+
```typescript
14+
const Snowflake = require('snowflake-promise').Snowflake;
15+
// or, for TypeScript:
16+
import { Snowflake } from 'snowflake-promise';
17+
18+
async function main() {
19+
const snowflake = new Snowflake({
20+
account: '<account name>',
21+
username: '<username>',
22+
password: '<password>',
23+
database: 'SNOWFLAKE_SAMPLE_DATA',
24+
schema: 'TPCH_SF1',
25+
warehouse: 'DEMO_WH'
26+
});
27+
28+
await snowflake.connect();
29+
30+
const rows = await snowflake.execute(
31+
'SELECT COUNT(*) FROM CUSTOMER WHERE C_MKTSEGMENT=:1',
32+
['AUTOMOBILE']
33+
);
34+
35+
console.log(rows);
36+
}
37+
38+
main();
39+
```
40+
41+
## More examples
42+
43+
* [Streaming result rows](../../examples/streaming.js)
44+
* [Using traditional Promise `then` syntax (and older versions of Node.js)](../../examples/oldSchool.js)
45+
* Node 4.0.0 is the oldest supported version

examples/oldSchool.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// This example shows how to use the library in traditional Promise style. You
3+
// might do this if you are using an older version of Node that doesn’t support
4+
// async/await, or simply if you prefer the Promise/then syntax.
5+
//
6+
// (You could also transpile async/await code using TypeScript or Babel, which
7+
// allows it to run on older versions of Node.)
8+
//
9+
// This library supports Node 4.0.0 and higher.
10+
//
11+
12+
//
13+
// Use this when processing large datasets (or when retrieving only a few rows
14+
// from a large result set). This is common when doing batch processing.
15+
//
16+
// This avoids loading the entire result set into memory, and lets you work on
17+
// one row at a time.
18+
//
19+
20+
var Snowflake = require('snowflake-promise').Snowflake;
21+
22+
function main() {
23+
var snowflake = new Snowflake({
24+
account: '<account name>',
25+
username: '<username>',
26+
password: '<password>',
27+
database: 'SNOWFLAKE_SAMPLE_DATA',
28+
schema: 'TPCH_SF1',
29+
warehouse: 'DEMO_WH'
30+
});
31+
32+
snowflake.connect()
33+
.then(function() {
34+
return snowflake.execute(
35+
'SELECT COUNT(*) FROM CUSTOMER WHERE C_MKTSEGMENT=:1',
36+
['AUTOMOBILE']
37+
);
38+
})
39+
.then(function(rows) {
40+
console.log(rows);
41+
})
42+
.catch(function(err) {
43+
console.error(err);
44+
})
45+
;
46+
}
47+
48+
main();

examples/streaming.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// Use this when processing large datasets (or when retrieving only a few rows
3+
// from a large result set). This is common when doing batch processing.
4+
//
5+
// This avoids loading the entire result set into memory, and lets you work on
6+
// one row at a time.
7+
//
8+
9+
const Snowflake = require('snowflake-promise').Snowflake;
10+
11+
async function main() {
12+
const snowflake = new Snowflake({
13+
account: '<account name>',
14+
username: '<username>',
15+
password: '<password>',
16+
database: 'SNOWFLAKE_SAMPLE_DATA',
17+
schema: 'TPCH_SF1',
18+
warehouse: 'DEMO_WH'
19+
});
20+
21+
await snowflake.connect();
22+
23+
// this query returns tens of thousands of rows
24+
const statement = snowflake.createStatement({
25+
sqlText: 'SELECT * FROM CUSTOMER WHERE C_MKTSEGMENT=:1',
26+
binds: ['AUTOMOBILE'],
27+
streamResult: true
28+
});
29+
30+
await statement.execute();
31+
32+
// How many rows did it return? (Without loading all of them.)
33+
console.log(`the query result set has ${statement.getNumRows()} rows`);
34+
35+
// let’s process rows 250-275, one by one
36+
// (if you omit the argument for streamRows(), all rows will be processed)
37+
statement.streamRows({ start: 250, end: 275 })
38+
.on('error', console.error)
39+
.on('data', row => console.log(`customer name is: ${row['C_NAME']}`))
40+
.on('end', () => console.log('done processing'))
41+
;
42+
}
43+
44+
main();

0 commit comments

Comments
 (0)