# @gopalroy/mysql-pool

> The incar global mysql pool

Latest version **1.3.9** (published 2017-02-02) · INCAR license · 0 weekly downloads

## Install

```sh
npm install @gopalroy/mysql-pool
pnpm add @gopalroy/mysql-pool
yarn add @gopalroy/mysql-pool
bun add @gopalroy/mysql-pool
```

## 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 | 1.3.9 |
| Published | 2017-02-02 |
| First published | 2017-02-02 |
| Weekly downloads | 0 |
| License | INCAR |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ghxiong |
| Maintainers | gopalroy |
| Keywords | mysql, database, pool |

## Links

- npm: https://www.npmjs.com/package/@gopalroy/mysql-pool
- Repository: http://dev.incardata.com.cn:7002/package/@gopalroy/mysql-pool
- npm.io page: https://npm.io/package/@gopalroy/mysql-pool

## Dependencies (5)

- [chalk](https://npm.io/package/chalk.md) ^0.5.1
- [debug](https://npm.io/package/debug.md) ^2.1.0
- [mysql](https://npm.io/package/mysql.md) ^2.5.3
- [moment](https://npm.io/package/moment.md) ^2.9.0
- [promise](https://npm.io/package/promise.md) ^6.0.1

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.3.9 (latest) — 2017-02-02

## README

# MySQL数据库连接池
整个程序应当共享同一个连接池.
此模块检查是否已经存在一个连接池,如果已经存在,那么直接返回这个已经存在的.

## QuickStart

```javascript
var mysqlPool = require('@gopalroy/mysql-pool');
// 配置连接选项
mysqlPool.config({
    host: '192.168.0.23',
    user: 'incar',
    password: 'pass1234',
    database: 'test'
});
// 查询
mysqlPool.pool.queryP("SELECT * FROM user WHERE id = ?", [1])
    .then(function(rows){
        console.log(rows);
    });
```

## API

### config(options)
配置数据库连接池选项
**options** 参见<https://github.com/felixge/node-mysql#pooling-connections>

### pool
返回连接池对象,参见<https://github.com/felixge/node-mysql#pooling-connections>

```javascript
var mysqlPool = require('@gopalroy/mysql-pool');
// 配置连接选项
mysqlPool.config({
    host: '192.168.0.23',
    user: 'incar',
    password: 'pass1234',
    database: 'test'
});
// 查询
mysqlPool.pool.query("SELECT * FROM user WHERE id = ?", [1], function(ex, rows){
        console.log(rows);
});
```

除[mysql](https://github.com/felixge/node-mysql)中支持的所有方法外,还增加了一个queryP方法.
queryP是Promise化的query.

### enableTrace(value)
是否输出SQL语句
**value** boolean. 默认为false,不输出SQL语句

输出SQL语句还需要设置环境变量 *DEBUG*=@gopalroy/mysql-pool

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