Better MySQL2

Better MySQL2 is a node package to interact with a database easier, inspiration from better-sqlite3 and mySQL2 but for a MySQL server.

What is Better MySQL2

Better mySQL2 is mysql2 wrapper for JavaScript, more is to be added to this module, we aim for the ease of use, you can test the API here https://www.freemysqlhosting.net and if you want to use the normal mySQL2 you can use that too.

Installation

npm i better-mysql2

Example

An Example of how to use better mySQL2.

const mysql = require("better-mysql2")

var db = new mysql.database({
    "host": "host",
    "user": "user"
    "password": "pass",
    "database": "database"
})

var row = db.prepare('SELECT * FROM users WHERE name = ?').get("foo")

console.log(row.firstName, row.lastName, row.email)

Last updated