Gathering detailed insights and metrics for mysql-connection-manager
Gathering detailed insights and metrics for mysql-connection-manager
Gathering detailed insights and metrics for mysql-connection-manager
Gathering detailed insights and metrics for mysql-connection-manager
mysql-connection-pool-manager
This is a mySQL Connection Pool Manager wrapper powered by mysqljs/mysql and allows for intelligent management & load balancing mysql connection pools.
mysql-pool-connection-manager
A simple promise wrapper around managing mysql pooled connections
project-connection-manager
This package give you the possibility to connect to the most of the popular database drivers as MySQL, SQLite, MongoDB etc
@piggly/mysql
An ESM/CommonJS library following Oriented-Object Programming pattern to manager a MySQL connection.
This module has been deprecated. You should use node-mysql's connection pooling instead (link in the readme)
npm install mysql-connection-manager
Typescript
Module System
Node Version
NPM Version
68.9
Supply Chain
96.8
Quality
74.9
Maintenance
50
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
8 Stars
65 Commits
6 Forks
4 Watchers
1 Branches
4 Contributors
Updated on Jan 12, 2024
Latest Version
0.0.14
Package Id
mysql-connection-manager@0.0.14
Size
5.28 kB
NPM Version
2.15.9
Node Version
4.5.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
6
Manages keep-alive signals, reconnections for a MySQL connection or connection pool.
Add to your application via npm
:
npm install mysql-connection-manager --save
This will install mysql-connection-manager
and add it to your application's package.json
file.
To have mysql-connection-manager
create the connection for you:
1var MySQLConnectionManager = require('mysql-connection-manager'); 2 3var options = { 4 host: 'localhost', 5 port: 3306, 6 user: 'db_user', 7 password: 'password', 8 database: 'db_name' 9}; 10 11var manager = new MySQLConnectionManager(options); 12 13manager.on('connect', function(connection) { 14 15 // Connected! 16 17}); 18 19// Pass the connection object to some other module, like this: 20var something = new SomeThing(someOtherOptions, manager.connection);
The connection object is the same as provided by node-mysql.
You can also pass an already existing node-mysql connection object to mysql-connection-manager
, like this:
1var mysql = require('mysql'); 2var MySQLConnectionManager = require('mysql-connection-manager'); 3 4var options = { 5 host: 'localhost', 6 port: 3306, 7 user: 'db_user', 8 password: 'password', 9 database: 'db_name' 10}; 11 12var connection = mysql.createConnection(options); 13var manager = new MySQLConnectionManager(options, connection);
To cleanly end the current connection:
1manager.endConnection();
A list of all available options:
1var options = { 2 host: 'localhost',// Host name for database connection. 3 port: 3306,// Port number for database connection. 4 user: 'connect_mng_test',// Database user. 5 password: 'password',// Password for the above database user. 6 database: 'connect_mng_test',// Database name. 7 autoReconnect: true,// Whether or not to re-establish a database connection after a disconnect. 8 reconnectDelay: [ 9 500,// Time between each attempt in the first group of reconnection attempts; milliseconds. 10 1000,// Time between each attempt in the second group of reconnection attempts; milliseconds. 11 5000,// Time between each attempt in the third group of reconnection attempts; milliseconds. 12 30000,// Time between each attempt in the fourth group of reconnection attempts; milliseconds. 13 300000// Time between each attempt in the fifth group of reconnection attempts; milliseconds. 14 ], 15 useConnectionPooling: false,// Whether or not to use connection pooling. 16 reconnectDelayGroupSize: 5,// Number of reconnection attempts per reconnect delay value. 17 maxReconnectAttempts: 25,// Maximum number of reconnection attempts. Set to 0 for unlimited. 18 keepAlive: true,// Whether or not to send keep-alive pings on the database connection(s). 19 keepAliveInterval: 30000// How frequently keep-alive pings will be sent; milliseconds. 20};
When useConnectionPooling
is set to true
, the manager.connection
object is a connection pool object returned by mysql.createPool
; see node-mysql for details.
Provide your SSL configuration options as you would when using the node-mysql module directly. Here's an example:
1var MySQLConnectionManager = require('mysql-connection-manager');
2
3var options = {
4 ssl: {
5 cert : fs.readFileSync( '/path/to/server-cert.pem'),
6 key : fs.readFileSync( '/path/to/server-key.pem')
7 }
8};
9
10var manager = new MySQLConnectionManager(options);
For more details on SSL options, see node-mysql.
The reconnect-related options may require a bit of additional explanation. With the default options shown above, the reconnect attempts will have the following delay pattern:
If the reconnectDelayGroupSize
was 3:
Any reconnect attempts beyond the last value in the reconnectDelay
array will simply use the last value from the reconnectDelay
array.
Alternatively you may supply a single integer value to the reconnectDelay
option to have one delay time between all reconnect attempts, like this:
1var options = { 2 reconnectDelay: 500 3};
There are a few events that can be listened for on the manager
object:
1manager.on('connect', function(connection) { 2 3 // A database connection has been established.. 4 5}); 6 7manager.on('reconnect', function(connection) { 8 9 // The database connection has been re-established.. 10 11}); 12 13manager.on('disconnect', function() { 14 15 // The database connection has been lost.. 16 17});
The manager
object is extended with the nodejs EventEmitter, so you can use all of the methods that it provides as well: on
, off
, once
, emit
, etc.
mysql-connection-manager
uses the debug module to output debug messages to the console. To output all debug messages, run your node app with the DEBUG
environment variable:
DEBUG=mysql-connection-manager node your-app.js
This will output log messages as well as error messages from mysql-connection-manager
.
There are a number of ways you can contribute:
readme.md
file. If you see a mistake, or think something should be clarified or expanded upon, please submit a pull requestBefore you contribute code, please read through at least some of the source code for the project. I would appreciate it if any pull requests for source code changes follow the coding style of the rest of the project.
Now if you're still interested, you'll need to get your local environment configured.
First, you'll need to pull down the code from GitHub:
git clone git@github.com:chill117/mysql-connection-manager.git
Second, you'll need to install the project dependencies as well as the dev dependencies. To do this, simply run the following from the directory you created in step 1:
npm install
Now, you'll need to set up a local test database:
1{ 2 host: 'localhost', 3 port: 3306, 4 user: 'connect_mng_test', 5 password: 'password', 6 database: 'connect_mng_test' 7};
These database credentials are located at test/config/database.js
With your local environment configured, running tests is as simple as:
npm test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More