npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ym-dbhelper

v2.5.0

Published

用参数调用数据库

Downloads

48

Readme

dbHelper

这是一个数据库执行SQL(参数形式),具体某种库在具体 ym-dhhelper-xxxx 中具体实现

ym-dhhelper-sqlite3 ym-dhhelper-mysql

初始化sqlite

const engineName = 'sqlite'; // sqlite/better-sqlite/mysql/mssql/oracle
const cnnParamSqlite = {
    file: path.join(__dirname, './demosl3/demo.sl3'),
}
const dhOption = { trace: true }
const db_sl3 = dhHelper.create(engineName, cnnParamSqlite, dhOption);

初始化better-sqlite

const engineName = 'better-sqlite'; // sqlite/better-sqlite/mysql/mssql/oracle
const cnnParamSqlite = {
    file: path.join(__dirname, './demosl3/demo.sl3'),
}
const dhOption = { trace: true } //日志
const db_sl3 = dhHelper.create(engineName, cnnParamSqlite, dhOption);

连接参数

const mssqlCnnParam = {
    server: '127.0.0.1',
    user: 'sa',
    password: 'haosql',
    database: 'yg_test',
    pool: {
        min: 0,
        max: 10
    },
};
const mysqlCnnParam = {
    connectionLimit: 10,
    waitForConnections: true, //若没有空闲连接 等待 false 不等待 //https://github.com/mysqljs/mysql#pooling
    host: '127.0.0.1',
    user: 'root',
    password: 'haosql',
    database: 'ygtest'
}
const sqliteCnnParam = {
    file: path.join(__dirname, '../../../demoApp/app/db/demoApp.sl3'),
    engine:'better-sqlite3',//使用 better-sqlite3 模块速度快的多  若没有配置此项 使用 node-sqlite3模块
}

初始化

const dh = require('dbhelper');
const db = dh.create('mysql', mysqlCnnParam, { trace: true });

调用

const sqlOBj_demo = {
    sql: 'select * from a_dict where (kind=:KIND)',
    params: 't4', //paramsObj 两种形式 一种数组 [v1,v2]  另一种是对象 {paramname1:v1,paramname2:v2,}
    is方言: false,
    dynFilter: { k: '%223%', V: 'a', },//动态过滤参数 可选
    isQuery:true ,//||false //是否查询
    page: { page: 1, rows: 3, },//分页 可选
    sortby: { LCT: 'asc', V: 'desc' }
};

dbHelper.execSqlObjs(sqlObj, function (err, ret) {

 });

//ret格式
const ret = {
    info: { 
        changes: 0 ,
        lastID:1    //
        },
    pageTotalCount:1000, //分页查询时的总页数    
    rows: []
};