-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add examples for each type of connection
- Loading branch information
1 parent
0606f92
commit 95f75cb
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var Redshift = require('../index.js'); | ||
|
||
var client = { | ||
user: 'user', | ||
database: 'database', | ||
password: 'password', | ||
port: 'port', | ||
host: 'host' | ||
}; | ||
|
||
var redshift = new Redshift(client); //no need to call connect(), without rawConnection, it automatically connects | ||
|
||
redshift.query('SELECT * FROM "Tags"', {raw: true}, function(err, data){ | ||
if(err) throw err; | ||
else{ | ||
console.log(data); | ||
//if you want to close client pool | ||
// but you won't be able to make subsequent calls because connection is terminated | ||
redshift.close(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var Redshift = require('../index.js'); | ||
|
||
var client = { | ||
user: 'user', | ||
database: 'database', | ||
password: 'password', | ||
port: 'port', | ||
host: 'host' | ||
}; | ||
|
||
var redshift = new Redshift(client, {rawConnection: true}); | ||
|
||
redshift.connect(function(err){ //create connection manually | ||
if(err) throw err; | ||
else{ | ||
redshift.query('SELECT * FROM "Tags"', {raw: true}, function(err, data){ //query redshift | ||
if(err) throw err; | ||
else{ | ||
console.log(data); | ||
redshift.close(); //close connection manually | ||
} | ||
}); | ||
} | ||
}); |