Basically I have a database where not many accesses appear but sadly grouped by two.
Firstly, there is a write access to the database Secondly, there is a read access.
The read access fails with the message that the database is locked ({ [Error: SQLITE_BUSY: database is locked] errno: 5, code: 'SQLITE_BUSY' }
) which is totally normal. But how can I make my read access to wait until the database is closed?
My current code:
var sql = "INSERT INTO chickenmilk (userID,channelID,message) VALUES (?,?,?)"
db.run(sql, userID, channelID, bot.fixMessage(message), function(err) {
console.log(err);
db.close();
});
And concurrent:
var sql = "SELECT userID, COUNT(message) as count FROM chickenmilk WHERE channelID LIKE ? GROUP BY userID";
db.all(sql, data, function(err,res) {
if(err) {
console.log(err);
return "";
}
callback(res); // data is used here
db.close();
});
Aucun commentaire:
Enregistrer un commentaire