New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@goodware/mysql

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@goodware/mysql

A mysql2-based connection helper

  • 2.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-86.21%
Maintainers
1
Weekly downloads
 
Created
Source

@goodware/mysql: A mysql2-based connection helper

Better documentation is coming

  • npm
  • git
  • API

Requirements

ES 2017

Installation

npm i --save @goodware/mysql

Features

  • Creates database connections via mysql2-promise, optionally from a pool, with exponential backoff retry
  • Handles AWS RDS passwordless IAM connections
  • Manages database transactions by wrapping begin/end around a function invocation

Notes

  • mysql2 Connection objects are from mysql2-promise, so their methods execute(), query() etc. return Promises.
  • If usePool is true, "await stop()" must be called on the MySqlConnector object if you wish to release the connections in the pool. Letting these objects merely go out of scope without stopping them will not close the connections.

Example

The following program outputs 'success' to the console.

const mysql = require('@goodware/mysql');
const pack = require('../package.json');

const config = {
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: process.env.DB_PASSWORD,
  database: 'mydb',
};

const connector = new mysql(config);

async () => {
  await connector.execute( async () => {
    const [results] = await connection.query(`select 'success' AS column`);
    console.log(results[0]).column;
  });

  await connector.stop();
}().then(console.info, console.error);

Keywords

FAQs

Package last updated on 12 Nov 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

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