-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
34 lines (31 loc) · 783 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var express = require("express");
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'root',
database : 'sys'
});
var app = express();
connection.connect(function(err){
if(!err) {
console.log("Database is connected ... \n\n");
} else {
console.log("Error connecting database ... \n\n");
}
});
app.get("/",function(req,response){
connection.query('SELECT * from employee LIMIT 2', function(err, rows, fields) {
connection.end();
if (!err){
/*response.writeHead(200, {
"Content-Type": "text/html"
});
response.write(rows);*/
console.log('The solution is: ', rows);
}
else
console.log('Error while performing Query.');
});
});
app.listen(3000);