-
Notifications
You must be signed in to change notification settings - Fork 0
/
DB.js
44 lines (33 loc) · 944 Bytes
/
DB.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
var mysql = require('mysql');
var connection = mysql.createConnection({
port: "3306",
host : 'localhost',
user : 'root',
password : '',
database : 'smartmobil',
insecureAuth : true
});
//console.log("Connected!");
connection.connect();
exports.adddata = function main( argument1,argument2, argument3, argument4 ) {
console.log("Asddas");
var sql = "INSERT INTO ENVIRONMENT (time, tempandhum, temperature, dust ) VALUES (?,?,?,?)";
var params =[ argument1, argument2, argument3, argument4]
connection.query(sql,params,function(err,rows,fields) {
if(err){
console.log(err);
}else{
console.log(rows.insertId);
} });
// connection.end();
};
/*
connection.connect();
connection.query('SELECT * from s', function(err, rows, fields) {
if (!err)
console.log('The solution is: ', rows);
else
console.log('Error while performing Query.', err);
});
connection.end();
*/