Lihat daftar modul node.js
- node-mysql — Modul node.js yang mengimplementasikan protokol MySQL
- node-mysql2 — Namun driver async JS murni lainnya. Pipelining, pernyataan yang disiapkan.
- node-mysql-libmysqlclient — Binding asinkron MySQL berdasarkan libmysqlclient
node-mysql terlihat cukup sederhana:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret',
});
connection.connect(function(err) {
// connected! (unless `err` is set)
});
Pertanyaan:
var post = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function(err, result) {
// Neat!
});
console.log(query.sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL'