Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mysql-promise

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-promise

Small wrapper for mysql that use promises.

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
987
increased by9.18%
Maintainers
1
Weekly downloads
 
Created
Source

mysql-promise

Small wrapper for mysql and mysql2 that use promises.

build status

Installation

This module is installed via npm:

$ npm install mysql-promise

Example Usage

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);

Keywords

FAQs

Package last updated on 02 May 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc