yarn add @xibang/mysql
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'));
})();
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'));
})();
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')));
})();
Apache 2.0
通过支付宝捐赠: