Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
mysql-promise
Advanced tools
Small wrapper for mysql and mysql2 that use promises.
This module is installed via npm:
$ npm install mysql-promise
var db = require('mysql-promise')();
db.configure({
"host": "localhost",
"user": "foo",
"password": "bar",
"database": "db"
});
db.query('UPDATE foo SET key = ?', ['value']).then(function () {
return db.query('SELECT * FROM foo');
}).spread(function (rows) {
console.log('Loook at all the foo', rows);
});
//using multiple databases, giving it a name 'second-db' so it can be retrieved inside other modules/files.
var db2 = require('mysql-promise')('second-db');
//check if has already been configured
if (!db2.isConfigured()) {
db2.configure({
"host": "localhost",
"user": "foo",
"password": "bar",
"database": "another-db"
});
}
db2.query('SELECT * FROM users').spread(function (users) {
console.log('Hello users', users);
});
Using mysql2
var mysql2 = require('mysql2');
var db = require('mysql-promise')(mysql2);
//with named instance
var db2 = require('mysql-promise')('second-db', mysql2);
2.1.0
FAQs
Small wrapper for mysql that use promises.
The npm package mysql-promise receives a total of 814 weekly downloads. As such, mysql-promise popularity was classified as not popular.
We found that mysql-promise 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.