Skip to content
MySQL 连接优化封装 https://npmjs.org/package/@xibang/mysql
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.editorconfig
.eslintignore
.eslintrc.yml
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package.json
yarn.lock

README.md

Xibang MySQL

github npm npm codecov codebeat badge Build Status

安装

yarn add @xibang/mysql

ES7 使用

POOL

const { pool } = require('@xibang/mysql');

(async(){
  // 传入配置,新建一个Pool,如果已有Pool则直接拿来使用
  const cn = await pool({
    host: '127.0.0.1',
    user: 'root',
    password: 'root',
    database: 'test'
  }); // 根据当前数据库配置创建一个连接
  console.log(await cn.query('SELECT 1'));
})();

CONNECTION

const { connection } = require('@xibang/mysql');

(async(){
  // 传入配置,新建一个连接,,如果已有连接则直接拿来使用
  const cn = await connection({
    host: '127.0.0.1',
    user: 'root',
    password: 'root',
    database: 'test'
  });
  console.log(await cn.query('SELECT 1'));
})();

FORMAT

const { pool, format } = require('@xibang/mysql');

(async(){
  const cn = await pool({
    host: '127.0.0.1',
    user: 'root',
    password: 'root',
    database: 'test'
  });
  console.log(await cn.query(format('SELECT 1')));
})();

License

Apache 2.0

通过支付宝捐赠:

qr

You can’t perform that action at this time.