forked from ysfdev/node-redshift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection_pooling.js
35 lines (29 loc) · 936 Bytes
/
connection_pooling.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
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
// using callbacks
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, uncomment redshift.close() line
// but you won't be able to make subsequent calls because connection is terminated
// redshift.close();
}
});
// using promises
redshift.query('SELECT * FROM "Tags"', {raw: true})
.then(function(data){
console.log(data);
// if you want to close client pool, uncomment redshift.close() line
// but you won't be able to make subsequent calls because connection is terminated
// redshift.close();
}, function(err){
throw err;
});