Socket
Socket
Sign inDemoInstall

@edu-tosel/mysql2-handler

Package Overview
Dependencies
11
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @edu-tosel/mysql2-handler

Make using mysql simpler with callback function, try...catch, more error objects


Version published
Weekly downloads
10
decreased by-93.38%
Maintainers
4
Install size
2.01 MB
Created
Weekly downloads
 

Readme

Source

mysql2-handler

The custom handler for mysql2 module.

Installation

npm install @edu-tosel/mysql2-handler

Environment Variables

export DB_HOST='localhost'
export DB_USER='root'
export DB_PASSWORD='password'
export DB_NAME='database'
export DB_PORT='3306'
export DATE_STRINGS='DATE' # or 'DATETIME' or 'TIMESTAMP'
# ...export DATE_STRINGS='DATETIME'
export CONNECTION_LIMIT='10'

Default configuration

  • DB_HOST: None
  • DB_USER: None
  • DB_PASSWORD: None
  • DB_NAME: None
  • DB_PORT: 3306
  • DATE_STRINGS: 'DATE'
  • CONNECTION_LIMIT: 5
  • TIMEZONE: 'UTC'

Usage

const mysqlHandler = require('@edu-tosel/mysql2-handler');
function select1(){
  return mysqlHandler.handler(async(connection)=>{
    const [rows, fields] = await connection.execute('SELECT 1 AS `one`');
    return rows; // [{one: 1}]
  });
}
select1().then(console.log).catch(console.error); // stdout: [{one: 1}]

Keywords

FAQs

Last updated on 15 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc