Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mysql-await

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-await

Simple MySQL Async/Await Connection Pool

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-10.54%
Maintainers
1
Weekly downloads
 
Created
Source

MySQL Async/Await Wrapper

Basic API for performing async/await MySQL queries on a pool. A new connection is created, queried, and released for each call to query().

Configuration:

{
  connectionLimit : 10,
  host            : 'example.org',
  user            : 'bob',
  password        : 'secret',
  database        : 'my_db'
}

Example

const fs = require(`fs`);
const mysql = require(`mysql-await`);

/** Self-executing asynchronous function so we can await results in this example */
(async () => {
  /** Create connection pool using loaded config */
  const db = mysql(JSON.parse(fs.readFileSync(`mysql-config.json`)));

  /** Perform query (opens a connection, runs query, releases connection) */
  const result = await db.query(`SELECT * FROM transactions WHERE ticker = ?`, [`DE`]);
  
  /** Log output */
  console.log(result);
  
  /** Close connection pool */
  db.end();
})();

Example Output

[ RowDataPacket {
    id: 56,
    account: 3,
    commission: 7,
    date: 2018-05-17T07:00:00.000Z,
    price: 146.71,
    shares: 20,
    ticker: 'DE',
    type: 1 },
  RowDataPacket {
    id: 112,
    account: 3,
    commission: 7,
    date: 2018-05-21T07:00:00.000Z,
    price: 158.83,
    shares: -20,
    ticker: 'DE',
    type: 2 } ]

License

MIT

Keywords

FAQs

Package last updated on 27 Sep 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc