Skip to content

Instantly share code, notes, and snippets.

@zhuangya
Created August 12, 2013 12:31
Show Gist options
  • Select an option

  • Save zhuangya/6210437 to your computer and use it in GitHub Desktop.

Select an option

Save zhuangya/6210437 to your computer and use it in GitHub Desktop.
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'vimscripts',
password: 'vimscripts',
database: 'vimscripts'
});
connection.connect(function(err) {
if(err) throw err
console.log('connected');
});
connection.query('SELECT 1 + 1 AS solution',
function(err, rows, fields) {
if(err) throw err;
console.log('The solution is: ', rows[0].solution);
});
console.log('job\'s done');
connection.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment