# sp-mysql

> super-project moudle for mysql operate.

Latest version **1.1.0** (published 2017-11-10) · Apache-2.0 license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2017-11-10 |
| First published | 2017-08-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| Author | cs_victor@126.com |
| Maintainers | dongwenxiao |
| Keywords | mysql |

## Links

- npm: https://www.npmjs.com/package/sp-mysql
- Homepage: https://github.com/dongwenxiao/sp-mysql#readme
- Issues: https://github.com/dongwenxiao/sp-mysql/issues
- npm.io page: https://npm.io/package/sp-mysql

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [mysql](https://npm.io/package/mysql.md) ^2.13.0
- [mysql2](https://npm.io/package/mysql2.md) ^1.2.0

## Recent versions

- 1.1.0 (latest) — 2017-11-10
- 1.0.3 — 2017-11-01
- 1.0.2 — 2017-08-07
- 1.0.1 — 2017-08-03
- 1.0.0 — 2017-08-01

## README

# sp-mysql
super-project moudle for mysql operate.


# Usage

## Init

Config More: https://github.com/mysqljs/mysql#connection-options
```js
import spMysql from 'sp-mysql'

const config = {
    host: '127.0.0.1',
    port: '3306',
    user: 'xxxx',
    password: 'xxxx',
    database: 'db_name'
}

const mysql = new spMysql(config)


```

## Query

```js


let sql = 'SELECT 1 + 1 AS Test'
let [result] = await mysql.query(sql)

// result 查询结果并保护下面数据
// { affectedRows, insertId } = result

```


## Debug

Use [debug](https://www.npmjs.com/package/debug) for log.

设置环境变量
```shell
set DEBUG=*             # 全部信息
set DEBUG=MySQL*        # MySQL相关信息，包括（info\log\errro）
set DEBUG=MySQL:info    # info信息
set DEBUG=MySQL:log     # log信息，执行sql
set DEBUG=MySQL:error   # error错误信息
```

## Test Connection

```js
mysql.testConnect()

// console => MySQL:info DB ['db_name'] connected √
//         => MySQL:info DB ['db_name'] connect failed X
```

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