-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslip_no_17B.js
43 lines (34 loc) · 1 KB
/
slip_no_17B.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
39
40
41
42
43
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "slipno17B"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
con.query("CREATE DATABASE IF NOT EXISTS slipno17B", function (err, result) {
if (err) throw err;
console.log("Database created");
});
var sql = "CREATE TABLE IF NOT EXISTS Employee (name VARCHAR(255), sal INT(20))";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("Table created");
});
var sql = "INSERT INTO Employee (name, sal) VALUES ?";
var data = [
['samarth', '9000'],
['Bhushan', '5000'],
['Patik', '7000']
];
con.query(sql, [data] ,function (err, result) {
if (err) throw err;
console.log("record inserted");
});
con.query("SELECT * FROM Employee ORDER BY sal ASC", function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});