
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
promise-mysql
Advanced tools
Promise-mysql is a wrapper for mysqljs/mysql that wraps function calls with Bluebird promises.
This will return a the promise of a connection object.
connectionOptions object: A connectionOptions object
A Bluebird Promise that resolves to a connection object
This will return a the promise of a pool object.
poolOptions object: A poolOptions object
A Bluebird Promise that resolves to a pool object
This will return a the promise of a poolCluster object.
poolClusterOptions object: A poolClusterOptions object
A Bluebird Promise that resolves to a poolCluster object
In addition to the connection options in mysqljs/mysql, promise-mysql accepts the following:
returnArgumentsArray boolean: If set to true then methods will return an array with the callback arguments from the underlying method (excluding the any errors) and the return value from the call.
mysqlWrapper function: A function that is passed the mysql object so that it can be wrapped with something like the aws-xray-sdk module. This function must either return the wrapped mysql object, return a promise of the wrapped mysql object or call the callback that is passed into the function.
reconnect boolean (default: true): If set to true then the connection will reconnect on the PROTOCOL_CONNECTION_LOST, ECONNRESET and PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR errors.
mysql mysql object: The mysql object
callback(error, success) function: A node-style callback that can be used to pass the wrapped version of the mysql object out of the wrapper function.
connection.query: Perform a query. See mysqljs/mysql documentation
connection.queryStream: Perform a query, but return the query object for streaming. See mysqljs/mysql documentation
connection.beginTransaction: Begin a transaction. See mysqljs/mysql documentation
connection.commit: Commit a transaction. See mysqljs/mysql documentation
connection.rollback: Roll back a transaction. See mysqljs/mysql documentation
connection.changeUser: Change the current connected user. See mysqljs/mysql documentation
connection.ping: Send a ping to the server. See mysqljs/mysql documentation
connection.end: End the connection. See mysqljs/mysql documentation
connection.destroy: Destroy the connection. See mysqljs/mysql documentation
connection.pause: Pause a connection. See mysqljs/mysql documentation
connection.resume: Resume a connection. See mysqljs/mysql documentation
connection.escape: Escape query values. See mysqljs/mysql documentation
connection.escapeId: Escape query identifiers. See mysqljs/mysql documentation
connection.format: Prepare a query. See mysqljs/mysql documentation
connection.on: Add a listener to the connection object. See mysqljs/mysql documentation for events that may be listened for.
In addition to the pool options in mysqljs/mysql, promise-mysql accepts the following:
returnArgumentsArray boolean: If set to true then methods will return an array with the callback arguments from the underlying method (excluding the any errors) and the return value from the call.
mysqlWrapper function: A function that is passed the mysql object so that it can be wrapped with something like the aws-xray-sdk module. This function must either return the wrapped mysql object, return a promise of the wrapped mysql object or call the callback that is passed into the function.
mysql mysql object: The mysql object
callback(error, success) function: A node-style callback that can be used to pass the wrapped version of the mysql object out of the wrapper function.
pool.getConnection: Get a poolConnection from the pool. See mysqljs/mysql documentation
pool.query: Get a connection from the pool, run a query and then release it back into the pool. See mysqljs/mysql documentation
pool.end: End all the connections in a pool. See mysqljs/mysql documentation
pool.escape: Escape query values. See mysqljs/mysql documentation
pool.escapeId: Escape query identifiers. See mysqljs/mysql documentation
pool.on: Add a listener to the pool object. See mysqljs/mysql documentation for events that may be listened for.
In addition to the methods in the connection object, poolConnections also has the following method:
poolConnection.release: Release a connection back to the pool. See mysqljs/mysql documentation
The options used to create a pool cluster. See mysqljs/mysql documentation
poolCluster.add: Adds a pool configuration. See mysqljs/mysql documentation
poolCluster.remove: Removes pool configurations. See mysqljs/mysql documentation
poolCluster.getConnection: Get a poolConnection from the pool cluster. See mysqljs/mysql documentation
poolCluster.of: Get a pool from the pool cluster. See mysqljs/mysql documentation
poolCluster.end: End all the connections in a pool cluster. See mysqljs/mysql documentation
poolCluster.on: Add a listener to the pool cluster object. See mysqljs/mysql documentation for events that may be listened for.
The main difference is that mysql.createPool now returns a promise. Besides this, the API is the same and you should be able to upgrade straight to v4. The only other difference is the extra options in the connectionOptions object.
The pool.releaseConnection has been removed, please use poolConnection.release instead.
FAQs
A bluebird wrapper for node-mysql
We found that promise-mysql 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.