MySQL connection pool for node.js on top of node-mysql.
Using a connection pool instead of a single connection should render a remarkable speed-up, when you have many short living connections, e.g. with message board applications.
var MySQLPool = MySQLPool;var pool =poolSize: 4user: 'root'password: 'root'database: 'test';pool;forvar i = 0; i < 10; ++ipool;
This module is currently not backed by proper unit testing. Nevertheless I found it stable for my testings.
If you find an error, please file an issue!
This module was only tested using node >= 0.4.x. It does not work with older versions of node.js.
The node-mysql-pool even works with unknown forks of node-mysql, as long as
Otherwise the requirements are the same as for node-mysql.
npm install mysql-pool
git clone email@example.com:Kijewski/node-mysql-pool.git node-mysql-pool
git submodule add firstname.lastname@example.org:Kijewski/node-mysql-pool.git deps/node-mysql-pool
The API of this module is as similar to node-mysql as possible, with two exceptions:
x, when not supplied while creation, are to be set to
When called back,
this will be the used connection. (You probably never need to
know which connection was actually used.)
creates a new, currently empty. Any property for the single connections or
the connectionpool, resp., can be set using the
If the parameter
poolsize is omitted, 1 is used.
Only if all connection attemps failed
err is supplied.
If some connections failed,
result.error will contain a list of Errors.
If some or all connections succeeded,
results.connections will contains the pool's size.
pool.poolSize = 1 pool.mysql = require("mysql")
pool.properties.xyz = undefined:
mysql.Clientobject. See the original documentation of node-mysql for more property related information.
client.useDatabase(database, cb) client.end([cb]) client.destroy()
For all methods you can invoke on a single connection, there is
methodnameAll(...) method. E.g. you can use
you want you to ping all connections for some reason.
cb will be called once for every connection affected. Subject to change!
All methods of the
Client object will be supported—with
destroy(...) being overwritten.
If you do not use a fork, that are currently:
query(sql, [params], cb) ping([cb])) statistics([cb])
See the original documentation of node-mysql for method related information.
format(sql, params) escape(val)
Will behave exactly like the original methods. They do not belong to a single connection.
Emitted if and only if an error occurred and no callback function was supplied. You should always supply a callback function!
cbshould be called only once.
node-mysql-pool is licensed under the MIT license.