Kolla in node.js-modullistan
- node-mysql — En node.js-modul som implementerar MySQL-protokollet
- node-mysql2 — Ännu en ren JS async-drivrutin. Pipelining, förberedda uttalanden.
- node-mysql-libmysqlclient — MySQL asynkrona bindningar baserade på libmysqlclient
node-mysql ser tillräckligt enkelt ut:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret',
});
connection.connect(function(err) {
// connected! (unless `err` is set)
});
Frågor:
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'