# easymysql

> Mysql client in cluster mode, based on node-mysql

Latest version **0.2.7** (published 2013-02-27) · 0 weekly downloads

## Install

```sh
npm install easymysql
pnpm add easymysql
yarn add easymysql
bun add easymysql
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.7 |
| Published | 2013-02-27 |
| First published | 2012-10-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6.9 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aleafs Zhang |
| Maintainers | aleafs |
| Keywords | mysql, cluster |

## Links

- npm: https://www.npmjs.com/package/easymysql
- Homepage: git@github.com:aleafs/mysql-cluster.git
- npm.io page: https://npm.io/package/easymysql

## Dependencies (2)

- [safequeue](https://npm.io/package/safequeue.md) >=0.0.2
- [mysql-robin](https://npm.io/package/mysql-robin.md) =2.0.8

## Recent versions

- 0.2.7 (latest) — 2013-02-27
- 0.2.6 — 2013-02-25
- 0.2.5 — 2013-02-01
- 0.2.4 — 2013-01-24
- 0.2.3 — 2013-01-24
- 0.2.2 — 2013-01-15
- 0.2.1 — 2013-01-15
- 0.2.0 — 2013-01-09
- 0.1.5 — 2013-01-06
- 0.1.4 — 2012-12-24
- 0.1.3 — 2012-12-13
- 0.1.2 — 2012-11-28
- 0.1.1 — 2012-11-26
- 0.1.0 — 2012-11-26
- 0.1.0-alpha — 2012-11-20
- … 3 more at https://npm.io/package/easymysql/versions

## README

[![Build Status](https://secure.travis-ci.org/aleafs/easymysql.png?branch=master)](http://travis-ci.org/aleafs/easymysql)

Click **[here](http://aleafs.github.com/coverage/easymysql.html)** to get the details of test coverage.

## About

`easymysql` 基于[`node-mysql`](https://github.com/felixge/node-mysql) 开发而来，提供一个简单、高可用的mysql连接基础库。主要特性如下：

* 支持query超时控制；
* 可控制的连接池支持，SQL总是尽可能早地被 **可用的** 空闲连接抢到并执行；
* 支持master-slave模式，基于`SHOW VARIABLES LIKE 'READ_ONLY'`方式自动判断主库和从库，运行期间自动感知主从切换；
* 即将支持事务。

## Install

```bash
$ npm install easymysql
```

## Usage

```javascript

var Client = require('easymysql');

var mysql = Client.create({
  'maxconnections' : 10
});

mysql.addserver({
  'host' : '127.0.0.1',
  'user' : 'write_user',
  'password' : ''
});
mysql.addserver({
  'host' : '127.0.0.1',
  'user' : 'read_user',
  'password' : ''
});

mysql.on('busy', function (queuesize, maxconnections, which) {
  // XXX: write log and monitor it
});

mysql.query('SHOW DATABASES', function (error, res) {
  console.log(res);
});

// bind params
mysql.query({
  sql: 'select * from user where user =:user',
  params: {user: 'xxoo'}
}, function (err, rows) {
  console.log(rows);
});


```

## Contributors

```
 project: easymysql
 commits: 161
 files  : 16
 authors: 
   135	aleafs                  83.9%
    21	zhaolei                 13.0%
     4	tangyao                 2.5%
     1	紫胤                  0.6%

 ```
## License

(The MIT License)

Copyright (c) 2012 aleafs and other easymysql contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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