-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql.js
64 lines (59 loc) · 2.04 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "root123"
});
module.exports = {
user_insert: function (userObj) {
//connect with the database
con.connect(function (err) {
if (err) throw err;
console.log(userObj.name)
console.log("Connected!");
var sql = "INSERT INTO dsri_users.dsri_user_details ("
+ "name,"
+ "username,"
+ "email,"
+ "faculty,"
+ "organization,"
+ "project_type,"
+ "project_name,"
+ "project_description,"
+ "github_url,"
+ "docker,"
+ "gpu_access,"
+ "exp_date,"
+ "shared,"
+ "users,"
+ "known,"
+ "data,"
+ "reg_date,"
+ "condition_val)"
+ "VALUES ("
+ "\'" + userObj.name + "\',"
+ "\'" + userObj.username + "\',"
+ "\'" + userObj.email + "\',"
+ "\'" + userObj.faculty + "\',"
+ "\'" + userObj.organization + "\',"
+ "\'" + userObj.projtype + "\',"
+ "\'" + userObj.projname + "\',"
+ "\'" + userObj.projdes + "\',"
+ "\'" + userObj.repo + "\',"
+ "\'" + userObj.docker + "\',"
+ "\'" + userObj.gpu + "\',"
+ "\'" + userObj.expdate + "\',"
+ "\'" + userObj.shared + "\',"
+ "\'" + userObj.nouser + "\',"
+ "\'" + userObj.known + "\',"
+ "\'" + userObj.data + "\',"
+ "\'" + userObj.reg_date + "\',"
+ "\'" + userObj.condition + "\'"
+ ")";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});
},
};