forked from RyanMG/DatsyScraper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.js
More file actions
27 lines (22 loc) · 707 Bytes
/
db.js
File metadata and controls
27 lines (22 loc) · 707 Bytes
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
var pg = require('pg');
var credentials = require('./dbconfig.json').db;
var conString = 'postgres://'+ credentials.username + ':' + credentials.password + '@' + credentials.localhost + '/' + credentials.name;
var client = new pg.Client(conString);
exports.connect = function(callback) {
client.connect(function(err) {
if(err) {
return console.error('could not connect to postgres', err);
} else {
callback();
}
});
}
exports.insertNewData = function(queryString) {
client.query(queryString, function(err, result) {
if(err) {
return console.error('error running query', err);
} else {
//console.log('successfully inserted row', result);
}
});
};