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-functions

v1.2.0

Published

A simple wrapper for [mysql](https://github.com/mysqljs/mysql) (A pure node.js JavaScript Client implementing the MySql protocol). All functions returns Promise. Use Node.js v.8 or higher with support for async/await.

Readme

mysql-functions

A simple wrapper for mysql (A pure node.js JavaScript Client implementing the MySql protocol). All functions returns Promise. Use Node.js v.8 or higher with support for async/await.

Installation

From npm.

npm install mysql-functions

Or from git.

npm install roboulbricht/mysql-functions

class TConnection

It is created in function TDatabase.connectPool. It has the same functions as TDatabase. You can have many opened TConnection.

class TDatabase

Function: connect()

Establishing the connection to the database.

var Database = require('mysql-functions');

var connection_string = {
    host: "localhost",
    user: "root",
    password: "password",
    database: "mydb"
}

var db = new Database(connection_string);
db.connect()
    .then(function() {
        console.log('connected');
        db.disconnect();
    })
    .catch(function(error) {
        console.log(error.message);
    });

Function: connectPool()

Establishing the connection to the database.

var Database = require('mysql-functions');

var connection_string = {
    connectionLimit : 10,
    host: "localhost",
    user: "root",
    password: "password",
    database: "mydb"
}

var db = new Database(connection_string);
db.connectPool()
    .then((con)=> {
        console.log('connected');
        db.disconnect(con); // or con.release();
    })
    .catch(function(error) {
        console.log(error.message);
    });

Function: execute(sql, params)

Execute the query without returning the result table. Good for insert queries.

  • sql {String} The SQL statement to be executed.
  • params {Array[]} An array of arrays containing the parameter definitions.
var Database = require('mysql-functions');

var connection_string = {
    host: "localhost",
    user: "root",
    password: "password",
    database: "mydb"
}

var db = new Database(connection_string);
db.connect()
    .then(async function() {
        console.log('connected');
        await db.execute('create temporary table kiosk(id int not null auto_increment, nazov varchar(255), typ int, primary key(id))');
        var result1 = await db.execute('insert into kiosk(nazov, typ) values(?, ?)', ['a3', 1]);
        console.log('identity1', db.identity);
        var result2 = await db.execute('insert into kiosk(nazov, typ) values(?, ?)', ['a4', 1]);
        console.log('identity2', db.identity);
        var result3 = await db.execute('insert into kiosk(nazov, typ) values(?, ?)', ['a5', 1]);
        console.log('identity3', db.identity);
        var q = await db.query('select * from kiosk where id>? order by id', [1]);
        console.log(q);
        db.disconnect();
    })
    .catch(function(error) {
        console.log(error.message);
    });

Property: identity

Return the last identity fro previous execute.

var result1 = await db.execute('insert into kiosk(nazov, typ) values(?, ?)', ['a3', 1]);
console.log('identity1', db.identity);

Function: query(sql, params)

Execute the query which returns the result table.

  • sql {String} The SQL statement to be executed.
  • params {Array[]} An array of arrays containing the parameter definitions.
var q = await db.query('select * from kiosk where id>? order by id', [1]);
console.log(q);

Property: fields

Return the fields from last query.

Function: beginTransaction()

Begin the transaction.

var Database = require('mysql-functions');

var connection_string = {
    host: "localhost",
    user: "root",
    password: "password",
    database: "mydb"
}

var db = new Database(connection_string);
db.connect()
    .then(async function() {
        console.log('connected');
        try {
        await db.beginTransaction();
        console.log('in transaction');
        //throw Error('This is error');
        await db.commitTransaction();
        console.log('commit');

        } catch(error) {
            await db.rollbackTransaction();
            console.log('error in transaction', error.message);
        };
        await db.disconnect();
        console.log('disconnected');
    })
    .catch(function(error) {
        console.log(error.message);
    });

Function: commitTransaction()

Commit the transaction.

Function: rollbackTransaction()

Rollback the transaction.