-
Notifications
You must be signed in to change notification settings - Fork 0
/
index1.js
38 lines (28 loc) · 841 Bytes
/
index1.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
35
36
37
38
const mysql =require('mysql');
const express=require('express');
var app=express();
const bodyparser=require('body-parser');
app.use(bodyparser.json);
app.listen(3000,()=>console.log('express server is running at port no3000'));
const pool=mysql.createPool({
connectionLimit:5,
host:'localhost',
user:'root',
password:'password',
database:'employee'
})
app.get('/employee',(req,res)=>{
pool.getConnection((err,connection)=>{
if(err) throw err
console.log('connected as id ${connection.threadId')
//query(sqlString, callback)
connection.query('SELECT * from employee',(err,rows) => {
connection.release()
if(!err) {
res.send(rows)
} else {
console.log(err)
}
})
})
})