diff --git a/connectDB.js b/db/connect.js similarity index 58% rename from connectDB.js rename to db/connect.js index 766b418..a298f71 100644 --- a/connectDB.js +++ b/db/connect.js @@ -1,5 +1,5 @@ const mysql = require('mysql'); -const config = require('./config'); +const config = require('../config'); var con = mysql.createConnection({ host: "test-db.verdnatura.es", @@ -9,4 +9,9 @@ var con = mysql.createConnection({ port: 3307, }); +con.connect(function(err) { + if (err) throw err; + console.log("Connected!"); +}); + exports.con = con; \ No newline at end of file diff --git a/db.sql b/db/db.sql similarity index 100% rename from db.sql rename to db/db.sql diff --git a/FillDB.js b/db/insert.js similarity index 77% rename from FillDB.js rename to db/insert.js index 93cce93..200c153 100644 --- a/FillDB.js +++ b/db/insert.js @@ -1,9 +1,9 @@ -const con = require('./connectDB.js') +const con = require('./connect.js') con.con.connect(function(err) { if (err) throw err; console.log("Connected!"); - var sql = "INSERT INTO vn.smartTag (code, shelvingFk, `level`) VALUES('A0A3B8200DA9', 'ABC', 2);"; + var sql = "INSERT INTO vn.smartTag (code, shelvingFk, `level`) VALUES('A0A3B8200DA1', 'ABC', 2);"; con.con.query(sql, function (err, result) { if (err) throw err; console.log("1 record inserted");