Skip to content

Instantly share code, notes, and snippets.

@arbo77
Created November 12, 2014 19:21
Show Gist options
  • Save arbo77/d6457ac4936d2e3d63f2 to your computer and use it in GitHub Desktop.
Save arbo77/d6457ac4936d2e3d63f2 to your computer and use it in GitHub Desktop.
NodeJS MySQL connection
var mysql = require('mysql');
var connection = mysql.createConnection(
{
host : 'localhost',
user : 'root',
password : '',
database : 'apps',
multipleStatements: true,
}
);
connection.connect();
var queryString = 'SELECT * FROM users';
connection.query(queryString, function(err, rows, fields) {
if (err) throw err;
for (var i in rows) {
console.log(JSON.stringify(rows[i]));
}
});
connection.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment