Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
mysql-pool
Advanced tools
Readme
node-mysql-pool is a MySQL connection pool for node.js on top of Felix Geisendörfer's MySQL client 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 = require("mysql-pool").MySQLPool;
var pool = new MySQLPool({
poolSize: 4,
user: 'root',
password: 'root',
database: 'test'
});
pool.query("SELECT 'Hello, World!' AS hello", function(err, rows, fields) {
if(err) throw err;
console.log(rows[0].hello);
});
for(var i = 0; i < 10; ++i) {
pool.query("SELECT SLEEP(2), ? AS i", [i], function(err, rows, fields) {
if(err) throw err;
console.log("Slept: " + rows[0].i);
});
}
You probably do not have to change anything if you already used node-mysql or any of its forks!
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 git@github.com:Kijewski/node-mysql-pool.git node-mysql-pool
git submodule add git@github.com: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 instance.properties.x
.When called back, this
will be the used connection. (You probably never need to
know which connection was actually used.)
mysqlPool.Pool([options])
creates a new, currently empty. Any property for the single connections or
the connectionpool, resp., can be set using the options
object.
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.
Defaults:
pool.poolSize = 1
pool.mysql = require("mysql")
pool.poolSize
:
pool.mysql
:
pool.properties.xyz = undefined
:
xyz
of the mysql.Client
object.
See the original documentation
of node-mysql for more property related information.client.useDatabase(database, cb)
client.end([cb])
client.destroy()
pool.useDatabase(database, cb)
:
pool.end([cb])
:
pool.destroy()
:
For all methods you can invoke on a single connection, there is
an equivalent methodnameAll(...)
method. E.g. you can use pool.pingAll(cb)
, if
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 connect(...)
, end(...)
,
useDatabase(...)
and 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.
Beware:
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!
cb
should be called
only once.node-mysql-pool is licensed under the MIT license.
FAQs
MySQL connection pool for node.js on top of node-mysql.
The npm package mysql-pool receives a total of 42 weekly downloads. As such, mysql-pool popularity was classified as not popular.
We found that mysql-pool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.