Enhanced MySQL Pool for Node.js

npm install emysql
1 downloads in the last week
4 downloads in the last month

Enhanced MySQL Pool Build Status

IREUL Guo ireul.guo@gmail.com

Enhanced MySQL Connection Pool for Node.js

Required Module

  • mysql
  • winston


emysql=require 'emysql'


Copy the config.sample.json to the place where you think is reasonable, correct the params, rename it at will.



NOTICE: the path send to emysql.init is for the function require, once the emysql module failed too much, it will entered failsafe module, emysql will automatically reload config file. It's suggested to use a absolute path.
WARN: init once, use everywhere

Fetch a Avaliable Connection

after init, get a avaliable connection is quite simple



NOTICE: emysql has a automatic balance system, each time you call the emysql(), or get the property emysql.conn, it will assign you a different connection


once the MySQL pool is no longer needed, you can shut it down.


The Logger

emysql use the default winston logger, if you want use your own winston logger instance, use emysql.setLogger(logger)

npm loves you