easy mysql_GitHub - aleafs/easymysql: mysql client in cluster, based on node-mysql

68747470733a2f2f7365637572652e7472617669732d63692e6f72672f616c656166732f656173796d7973716c2e706e673f6272616e63683d6d6173746572

68747470733a2f2f67656d6e617369756d2e636f6d2f616c656166732f656173796d7973716c2e706e67

Click

About

easymysql 基于node-mysql 开发而来,提供一个简单、高可用的mysql连接基础库。主要特性如下:

支持query超时控制;

可控制的连接池支持,SQL总是尽可能早地被 可用的 空闲连接抢到并执行;

支持master-slave模式,基于SHOW VARIABLES LIKE 'READ_ONLY'方式自动判断主库和从库,运行期间自动感知主从切换;

即将支持事务。

Install

$ npm install easymysql

Usage

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:

135aleafs 83.9%

21zhaolei 13.0%

4tangyao 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值