-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprimarykey.js
29 lines (28 loc) · 953 Bytes
/
primarykey.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
const mysql = require('mysql');
require("dotenv").config();
var con = mysql.createConnection({
host:"localhost",
database:"newdatabase",
user:"root",
password:process.env.PASS
});
con.connect((err) => {
if (err) throw err;
console.log("connected");
var q = "CREATE TABLE Customerm (cid int primary key,cname VARCHAR(20),address VARCHAR(225))";
// con.query(q,(err,r) => {
// if (err) throw err;
// console.log(r);
// });
var q2 = "CREATE TABLE orders1 (id INT PRIMARY KEY,foreign key(id) references Customerm(cid),orderTotal DECIMAL(9,2))";
con.query(q2,(err) => {
if (err) throw err;
console.log("done with foreing key");
});
let array = [[101,'wasim','pune'],[102,'aryan','pune']];
var ql = "insert into student values ?";
con.query(ql,[array],(err,r) => {
if (err) throw err;
console.log(r.affectedRows);
});
});