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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mysql-htqw

v0.1.0

Published

A secondary encapsulation for the nodejs mysql2 library.

Readme

mysql-htqw

简介

针对于nodejs mysql2的二次封装

贡献者

安装

npm install mysql-htqw --save

实现功能

  1. 数据库连接
  2. 表操作(创建表、删除表、插入、查询、更新、删除信息)
  3. 关闭连接

教程

const mysql = require('mysql-htqw');

(async function main () {
    const connect = new mysql({
        host: 'localhost', // *数据库主机 必选
        user: 'test', // 数据库用户名,可选 默认root
        password: 'test', // 数据库密码,可选 默认无
        database: 'test', // *数据库名称 必选
        port: 3306 // 数据库端口,可选 默认3306
    })
    console.log(await connect.table.create(
        'test', // *表名 必选
        {
            // 字段名称: '类型'
            id: 'INT',
            name: 'TEXT',
            age: 'INT'
        } // *字段类型 必选
    )) // 创建表
    console.log(await connect.table.insert(
        'test', // *表名 必选
        {
            // 字段名称: '值'
            id: '1',
            name: '"htqw"',
            age: '18'
        } // *插入数据 必选
    )) // 插入数据
    console.log(await connect.table.select(
        'test', // *表名 必选
        ['id', 'name', 'age'], // *查询字段 必选
        'id = 1' // 查询条件 可选
    )) // 查询数据
    console.log(await connect.table.update(
        'test', // *表名 必选
        {
            // 字段名称: '值'
            name: '"htqw2"',
            id: '1',
            age: '19'
        }, // *更新数据 必选
        'id = 1' // 更新条件 可选
    )) // 更新数据
    console.log(await connect.table.select(
        'test', // *表名 必选
        ['id', 'name', 'age'], // *查询字段 必选
        'id = 1' // 查询条件 可选
    )) // 查询数据
    console.log(await connect.table.delete(
        'test', // *表名 必选
        'id = 1' // 删除条件 可选
    )) // 删除数据
    console.log(await connect.table.drop(
        'test' // *表名 必选
    )) // 删除表
    console.log(await connect.end()) // 关闭连接
})()
  1. 使用异步
  2. 每个方法都有返回值,返回值是Promise对象
    • 当成功时,返回结果
    • 当失败时,返回错误信息

API

  • new mysql(options) 创建连接
    • options 数据库配置
      • host 数据库主机
      • user 数据库用户名,可选 默认root
      • password 数据库密码,可选 默认无
      • database 数据库名称
      • port 数据库端口,可选 默认3306
  • mysql.table 操作表
    • mysql.table.create(table, cols) 创建表
      • table 表名
      • cols 字段类型
        • 字段名称: '类型'
    • mysql.table.drop(table) 删除表
      • table 表名
    • mysql.table.insert(table, data) 插入数据
      • table 表名
      • data 插入数据
    • mysql.table.select(table, cols, where) 查询数据
      • table 表名
      • cols 查询字段
        • ['字段名称1', '字段名称2', ...]
      • where 查询条件
    • mysql.table.update(table, data, where) 更新数据
      • table 表名
      • data 更新数据
        • {字段名称: '值', ...}
      • where 更新条件
    • mysql.table.delete(table, where) 移除某个信息
      • table 表名
      • where 删除条件
  • mysql.end() 关闭连接

注意

  • mysql.table.createmysql.table.dropmysql.table.insertmysql.table.selectmysql.table.updatemysql.table.deletemysql.end 方法都有返回值,返回值是Promise对象
    • 当成功时,返回结果
    • 当失败时,返回错误信息

联系

参与贡献

  1. Fork本项目
  2. 创建Feat_xxx(功能)_xxx(你的昵称)分支
  3. 新建Feat_xxx(功能)_xxx(你的昵称).md文件,描述你的功能
  4. 提交代码
  5. 新建Pull Request