Tuesday, 13 August 2013

node mariasql query won't terminate / does the mariadb.end() funciton wait for all the queries

node mariasql query won't terminate / does the mariadb.end() funciton wait
for all the queries

I am running the following script with node:
var mariadb = require("mariasql");
var db = new mariadb();
db.connect({
host: "localhost",
user: "root",
password: "bus1708v2.0",
db: "test"
});
db.query("INSERT INTO Persons (LastName, FirstName) VALUES ('Some', 'Name')")
.on("result", function(result){
result.on("end", function(info){
console.log(info);
console.log(result);
});
});
It successfully inserts into the database but I have to ctrl-c to
terminate the script
Update
I just realized i need to put db.end(); at the very end
In this case does db.end() wait for all the queries to finish?

No comments:

Post a Comment