The below NodeJS app is running perfectly fine without process.exit() when I add process.exit() it closes the window after executing (which I what I am after) but it's not executing the SQL query.
var mysql = require('mysql')
var conn = mysql.createPool({
connectionLimit : 10000,
host: "localhost",
user: "root",
password: "password",
database: "mydatabase",
port: 3306
});
var values = ""
for (var i=0; i < 300; i++) {
var pub = //some randomvalue
var hub = //some randomvalue
values += "('"+pub + "', '" + hub + "'), "
console.log(i);
}
var valuesx = values.slice(0, -2)
var sql = "INSERT INTO `test` (pub, hub) VALUES "
var sqlx = sql + valuesx;
conn.getConnection(function(err, con) {
if (err) throw err
con.query(sqlx)
con.release();
});
process.exit(0)
The above code doesn't insert into MySQL
If I remove process.exit(0) it inserts into MySQL