File size: 763 Bytes
81d22d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
var config = require('./config');

var connection = {};

if (config.SAVE_TO_DB) {

    var mysql = require('mysql2');

    //create connection
    var db_config = {
        host: config.DB_HOST,
        port: config.DB_PORT,
        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." , err);
        } else {
            console.log("New connection established with the database. ")
        }
    });

}

module.exports = connection;