# mysql-promise

> Small wrapper for mysql that use promises.

Latest version **5.0.0** (published 2018-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install mysql-promise
pnpm add mysql-promise
yarn add mysql-promise
bun add mysql-promise
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2018-09-18 |
| First published | 2013-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 2 |
| Unpacked size | 11.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Martin Jonsson |
| Maintainers | martinj |
| Keywords | mysql, promise |

## Links

- npm: https://www.npmjs.com/package/mysql-promise
- Repository: https://github.com/martinj/node-mysql-promise
- Homepage: https://github.com/martinj/node-mysql-promise#readme
- Issues: https://github.com/martinj/node-mysql-promise/issues
- npm.io page: https://npm.io/package/mysql-promise

## Dependencies (2)

- [mysql](https://npm.io/package/mysql.md) ^2.16.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.2

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2018-09-18
- 4.1.0 — 2016-12-01
- 4.0.0 — 2016-11-18
- 3.1.0 — 2016-08-24
- 3.0.0 — 2016-05-23
- 2.1.0 — 2016-05-02
- 2.0.0 — 2016-04-05
- 1.5.0 — 2016-02-16
- 1.4.0 — 2015-06-06
- 1.3.1 — 2015-04-16
- 1.3.0 — 2014-07-02
- 1.2.1 — 2014-06-30
- 1.2.0 — 2014-06-30
- 1.0.1 — 2014-03-03
- 1.0.0 — 2014-03-03
- … 2 more at https://npm.io/package/mysql-promise/versions

## README

# mysql-promise

Small wrapper for [mysql](https://www.npmjs.com/package/mysql) and [mysql2](https://github.com/sidorares/node-mysql2) that use promises.

[![Build Status](https://travis-ci.org/martinj/node-mysql-promise.svg?branch=master)](https://travis-ci.org/martinj/node-mysql-promise)

## Installation

This module is installed via npm:

``` bash
$ 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](https://github.com/sidorares/node-mysql2)

	var mysql2 = require('mysql2');
	var db = require('mysql-promise')();
	var opts = {
		"host": "localhost",
		"user": "foo",
		"password": "bar",
		"database": "db"
	};

	db.configure(opts, require('mysql2'));


Use different promise implementation

	var db = require('mysql-promise')();

	db.configure(dbOpts, null, PromiseImpl);

---
_Source: https://npm.io/package/mysql-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
