mysql-with-promises
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ABOUT

This module acts as a wrapper for mysql using promises to make your workflow easier.

TO INSTALL

npm i mysql-with-promises

TO CONNECT

CommonJS

const connect = require('mysql-with-promises').connect const connection = connect('localhost', 'root', 'password', '<database-name (optional)'>')

ES6 Modules

import {connect} from 'mysql-with-promises' const connection = connect('localhost', 'root', 'password', '<database-name (optional)'>')

You can also connect using a url by passing the url into the connect function const connection = connect(url)

TO QUERY

Standard Promise Syntax

    console.log(response.result)
    console.log(response.fields)
})

async/await

Wrapped in an async function with a try/catch block

    try {
    const response = await connection.query(sql)
    console.log(response.result)
    console.log(response.fields)
   } catch (error) {
        console.log(error)
   }
    
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    4
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    4
  • 1.0.0
    0

Package Sidebar

Install

npm i mysql-with-promises

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

29 kB

Total Files

23

Last publish

Collaborators

  • ishaangupte21