forked from HackYourFuture/databases
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert-values.js
More file actions
26 lines (24 loc) · 900 Bytes
/
Copy pathinsert-values.js
File metadata and controls
26 lines (24 loc) · 900 Bytes
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
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'hyfuser',
password : 'hyfpassword',
database : 'class17'
});
connection.connect();
var insert_queries = [
"insert into students values (103, 'Ahmad', '1986-01-11', 8.3, 'm')",
"insert into students values (104, 'Rim', '1979-11-01', 8.7, 'f')",
"insert into students values (105, 'Rabia', '1978-05-30', 8.1, 'f')",
"insert into students values (106, 'Karam', '1994-02-02', 8.8, 'm')"
]
for(var i in insert_queries){
console.log("Going to run ", insert_queries[i])
connection.query(insert_queries[i], function (error, results, fields) {
if (error) {
throw error;
}
console.log("the reply is ", results[0]);
});
}
connection.end();