Mysql Pool

download Mysql Pool

If you can't read please download the document

description

mysql pool using nodejs

Transcript of Mysql Pool

var mysql = require('mysql');var config = require('./config');var pool = mysql.createPool({ connectionLimit : 10, host: config.mysql.host, user: config.mysql.user, password: config.mysql.password, database: config.mysql.database});pool.getConnection(function(err, connection) { if (err) { console.log("mariadb disconnected"); } else { connection.query('SELECT 1 ', function(err, rows) { if (rows) { console.log("mariadb connected"); } connection.release(); }); }});exports.getConnection = function getConnection(callback) { pool.getConnection(function(err, connection) { if (err) { callback(err, null); } else { callback(err, connection); } });};