You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mysql-async-simple

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-async-simple

An async wrapper for mysql client

1.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

This package wraps the mysql nodejs client package (https://www.npmjs.com/package/mysql) into an async/await library.

Basic Example

const { makeDb } = require('mysql-async-simple');
const mysql = require("mysql");

const connection = mysql.createConnection({
    host: process.env.HOST,
    user: process.env.USER,
    password: process.env.PASSWORD,
    database: process.env.DB
});
const db = makeDb();
await db.connect(connection);

try {
    const users = await db.query(connection, 'SELECT * FROM users');
} catch (e) {
    // handle exception
} finally {
    await db.close(connection);
}

For more information visit github https://github.com/hashgit/mysql-async-simple#readme

NPM

Available to install as a package at npm registry (https://www.npmjs.com/package/mysql-async-simple)

Credits

This package is based on this blog post by Michał Męciński https://codeburst.io/node-js-mysql-and-async-await-6fb25b01b628

Keywords

mysql

FAQs

Package last updated on 09 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts