-
Notifications
You must be signed in to change notification settings - Fork 0
/
slip_no_6_B.js
61 lines (42 loc) · 1.46 KB
/
slip_no_6_B.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "slipno6"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
// //database create
// con.query("CREATE DATABASE slipno6", function (err, result) {
// if (err) throw err;
// console.log("Database created");
// });
// //table create
// var table = "CREATE TABLE slipno6 (name VARCHAR(255), city VARCHAR(255))"
// con.query(table, function (err, result) {
// if (err) throw err;
// console.log("Table created");
// });
// // //data insert
// var data1 = "INSERT INTO slipno6 (name, city) VALUES ('Samarth Mali', 'Nandurbar')";
// var data2 = "INSERT INTO slipno6 (name, city) VALUES ('Pratik Swami', 'Pune')";
// var data3 = "INSERT INTO slipno6 (name, city) VALUES ('Bhushan Deshmukh', 'Akola')";
// con.query(data1, function (err, result) {
// if (err) throw err;
// console.log( "no. 1 record inserted");
// });
// con.query(data2, function (err, result) {
// if (err) throw err;
// console.log( "no. 2 record inserted");
// });
// con.query(data3, function (err, result) {
// if (err) throw err;
// console.log( "no. 3 record inserted");
// });
con.query("SELECT city, name FROM slipno6", function (err, result, fields) {
if (err) throw err;
console.log(result);
});
});