Socket
Socket
Sign inDemoInstall

mysql-singleton

Package Overview
Dependencies
11
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mysql-singleton

Singleton MySQL connection


Version published
Weekly downloads
14
Maintainers
1
Install size
1.02 MB
Created
Weekly downloads
 

Readme

Source

Connecting MySQL database.

example

npm install mysql-singleton --save
const mysql_singleton = require('mysql-singleton');
const config = {
  host: 'localhost',
  user: 'root',
  password: '',
  database: 'database'
}
// adding config
mysql_singleton.config(config)

// getting connection using good old callback 
 mysql_singleton.getConnection(function(err,connection){
        // handle err or connection 
});

// using async await 
const connection = await mysql_singleton.getConnectionPromise();

// writing queries 
 connection.query("select * from table",(err,result)=>{
    // handle result or err             
})

// don't for get to realase the connection after it's use
connection.release(); 

Keywords

FAQs

Last updated on 16 Dec 2017

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