Node-poormansmysql is a project mainly written in JavaScript, based on the MIT license.
MySQL driver module for node.js that executes queries using the mysql command-line client.
node-poormansmysql is a MySQL driver for node.js that executes queries using the mysql command-line client.
MysqlConnection Methods:
(constructor) MysqlConnection(config)
Parameters:
config: (Object) An object containing the necessary connection information to connect to the MySQL server and perform queries. At least the user and password should be supplied. The default configuration is:
user: null,
password: null,
db: null,
host: 'localhost',
port: 3306,
force: false, // execute ALL queries in the case of a query error
connect_timeout: 0, // the time to wait for a connection to the MySQL server (in seconds)
execute_timeout: 0 // the time to wait for ALL queries to execute (in seconds) (TODO)
MysqlConnection Events:
Utility methods exposed:
var pmm = require('./node-poormansmysql'), sys = require('sys');
var fieldvalue = "o'reilly";
var conn = new pmm.MysqlConnection({user: 'foo', password: 'bar', db: 'baz'});
conn.addListener('error', function(err) {
sys.puts('Uh oh, ' + err);
});
conn.query("SELECT * FROM table",
function(row) {
sys.puts("Got result for first query: " + JSON.stringify(row));
},
function(totalRows) {
sys.puts("First query is done! Retrieved " + totalRows + " row(s)");
},
function(err) {
sys.puts("First query resulted in error: " + err);
}
);
conn.query("SELECT * FROM table2 WHERE field = '" + pmm.escape(fieldvalue) + "'",
function(row) {
sys.puts("Got result for second query: " + JSON.stringify(row));
},
function(totalRows) {
sys.puts("Second query is done! Retrieved " + totalRows + " row(s)");
},
function(err) {
sys.puts("Second query resulted in error: " + err);
}
);
conn.execute();
See LICENSE file.