The MySqlDB Class Library is a high level wrapper around the MySql.
Requirements:
- Node.js
- npm (Node.js package manager)
npm install mysqldb.js
Including all libraries, for access to extra methods:
var MySqlConnection = require('mysqldb.js');
var server = "localhost";
var port = 3306;
var database = "mydb";
var username = "root";
var password = "";
//var mysql = new MySqlConnection(connectionString);
var mysql = new MySqlConnection(server, port, database, username, password);
var sql = "SELECT name, surname, email FROM posts ORDER BY name;";
// if connection is successful
mysql.sql_query(sql, function (err, result, fields) {
// if any error while executing above query, throw error
if (err) throw err;
// if there is no error, you have the result
console.log([result]);
});