forked from sunny9577/proxy-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
32 lines (24 loc) · 738 Bytes
/
db.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
var config = require('./config');
var connection = {};
if (config.SAVE_TO_DB) {
var mysql = require('mysql');
//create connection
var db_config = {
host: config.DB_HOST,
user: config.DB_USER,
password: config.DB_PASS,
database: config.DB_NAME,
multipleStatements: true,
connectionLimit: 50
};
connection = mysql.createPool(db_config);
//- Establish a new connection
connection.getConnection(function(err) {
if (err) {
console.log("Cannot establish a connection with the database. Exiting....");
} else {
console.log("New connection established with the database. ")
}
});
}
module.exports = connection;