This module acts as a wrapper for mysql using promises to make your workflow easier.
npm i mysql-with-promises
const connect = require('mysql-with-promises').connect
const connection = connect('localhost', 'root', 'password', '<database-name (optional)'>')
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)
console.log(response.result)
console.log(response.fields)
})
try {
const response = await connection.query(sql)
console.log(response.result)
console.log(response.fields)
} catch (error) {
console.log(error)
}
}