Skip to content

Instantly share code, notes, and snippets.

@obowersa
Created April 4, 2017 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obowersa/9a15aa0d47df4166f62eef939a82e77d to your computer and use it in GitHub Desktop.
Save obowersa/9a15aa0d47df4166f62eef939a82e77d to your computer and use it in GitHub Desktop.
var http = require('http');
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
database: 'node'
});
console.log('MySQL Connection details '+connection);
http.createServer(function (request, response)
{
console.log('Creating the http server');
connection.query('SELECT id, content FROM test WHERE id IN (?,?)',[1, 2], function(err, rows, fields)
{
response.writeHead(200, { 'Content-Type': 'application/json'});
response.end(JSON.stringify(rows));
response.end();
});
}).listen(8084);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment