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

evanpatchouli-mysql

v1.0.22

Published

nodejs mysql tool

Downloads

6

Readme

evanpatchouli-mysql

evanpatchouli-mysql is js-tool for MySQL, whick can help you use MySQL easier in node.

This tool is at birth and it will grow up fastly in the future.

Latest Version: 1.0.22

v1.0.22:

  • now you can create and use more connection pool rather than only the one default pool.
  • improve the HELP.md.
  • improve the type hint.

v1.0.21: a patch

v1.0.20:

  • Intelligent Hint Type declared with typescript so that the intelligent coding hint is supported.
  • 1 Bug Fixed The bug of lifetime of conn is fixed.

v1.0.18: add two functions: newDb and delDb

v1.0.17: a patch, export bug has been fixed

v1.0.16: a patch

v1.0.15: a patch

v1.0.14: a patch

v1.0.13:

JsDoc has been added!

v1.0.12:

Compiled into CommonJs: since v1.0.11, the sql.js module will be compiled into commonjs by babel, and you can enjoy it with both of cjs and mjs.

Standardlize: the function name in conn, pool and db. One of my friend told me that the name "get" confused him to think it as "get a connection", and this is just when I realized that I should make the names more clear and easy at the same time.

One New Feature: the db has mode! It has two options: "debug" and "non-debug", you can set it at db.mode, the "non-debug" mode only returns one of the entire mysql.js result, and "debug" mode returns entirely, with the sql str and some message printed in console working like sql log.

One New Change: under "non-debug" mode, the action like update, insert, delete will all return one number, and the meanings are a bit different between them: upd, return the result = affectedRows + changedRows - 1, and it's easy to understand the three value of it, 1 means success, 0 means the new is the same as new, -1 means the target record doesn't exist.insert and delete return affectedRows, 1 means success and 0 instead.

Install

npm install evanpatchouli-mysql

Code Resource

https://github.com/Evanpatchouli/evanpatchouli-mysql

Useage

Tip: the sql-action is a packaged Promise, I suggest to use 'async / await', but raw Promise also works if you prefer it.

Separate Introduction

type: "Moudle"

import db from "evanpatchouli-mysql/lib/sql.js";

type: "CommonJs"

let db = require("../index.js");

quick sql

let result = db.sel('select * from user');

sql in a quick persistent conn

let conn = await db.conn("localhost", 3306, "root", "root", "springdemo");
let result = conn.get('select * from user');

close a conn

conn.close();

init connection pool

// example db.pool.init(host, port, user, password, database)
db.pool.init('localhost',3306,'root','root','springdemo');

quick sql in pool

let result = db.pool.sel('select * from user')

do sql in a certain conn in pool

let conn = db.pool.conn();
let result = conn.sel('select * from user')

close pool

db.pool.close();

Result : Output

debug mode output:

sql: insert into user (name,pwd) values ('user3','userpwd')
under: springdemo
connection: conn1 in pool persistent
{
  sql: "insert into user (name,pwd) values ('user3','userpwd')",
  res: {
    fieldCount: 0,
    affectedRows: 1,
    insertId: 17,
    serverStatus: 2,
    warningCount: 0,
    message: '',
    protocol41: true,
    changedRows: 0
  }
}

More

More usage can be saw in HELP.md