-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase_mysql.js
45 lines (43 loc) · 896 Bytes
/
database_mysql.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
var mysql = require('mysql');
var conn = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'victorica7',
database : 'o2'
});
conn.connect();
/*
var sql = 'select * from topic';
conn.query(sql, function(err, rows, fields){
if(err){
console.log(err);
} else {
for(var i=0; i<rows.length; i++){
console.log(rows[i].author);
}
}
});
conn.end();
*/
/*
var sql = 'insert into topic (title, description, author) values(?, ?, ?)';
var params = ['Supervisor', 'Watcher', 'graphittie'];
conn.query(sql, params, function(err, rows, fields){
if(err){
console.log(err);
} else {
console.log(rows.insertId);
}
})
conn.end();
*/
var sql = 'DELETE from topic where id=?';
var params = [1];
conn.query(sql, params, function(err, rows, fields){
if(err){
console.log(err);
} else {
console.log(rows);
}
});
conn.end();