async-mysql

1.0.1 • Public • Published

async-mysql

NPM version Travis build status Dependency Status

async-mysql is a wrapper for mysql that uses ES7 async functions.

Usage

let main;
 
// async/await can be used only within an async function.
main = async () => {
    let mysql = require('async-mysql'),
        connection,
        rows;
 
    connection = await mysql.connect({
        host: 'localhost'
    });
 
    rows = await connection.query('SELECT 1');
    // [{'1': 1}]
 
    try {
        await connection.query('INVALID_QUERY');
    } catch (e) {
        e;
        // [Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID_QUERY' at line 1]
    }
};
 
main();

Readme

Keywords

Package Sidebar

Install

npm i async-mysql

Weekly Downloads

197

Version

1.0.1

License

BSD-3-Clause

Last publish

Collaborators

  • gajus