2017-05-30 06:06:14 +00:00
|
|
|
var mysql = require('mysql');
|
2017-05-31 11:46:18 +00:00
|
|
|
var settings = require('./settings.js');
|
2017-05-30 06:06:14 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2017-05-30 06:06:14 +00:00
|
|
|
/**
|
|
|
|
* Variable de instancia del pool
|
|
|
|
*/
|
|
|
|
pool: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Iniciar pool de conexión con la base de datos
|
|
|
|
*/
|
|
|
|
init: function() {
|
2017-05-31 11:46:18 +00:00
|
|
|
this.pool = mysql.createPool(settings.mysql());
|
2017-05-30 06:06:14 +00:00
|
|
|
|
|
|
|
this.pool.getConnection(function(error, connection) {
|
|
|
|
if (error) {
|
2017-06-01 06:51:29 +00:00
|
|
|
console.log('No se ha podido establecer la conexión con la base de datos. ' + error.code);
|
2017-05-30 06:06:14 +00:00
|
|
|
} else {
|
2017-06-01 06:51:29 +00:00
|
|
|
console.log('Conexión con la base de datos establecida');
|
2017-05-30 06:06:14 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|