0

I'm currently trying to to test a little server with multiple asynchronous HTTP-requests, however my sqlite3 database seems to block simultaneous queries issuing SQLITE_BUSY.

db.exec(query, (err) => {
    if (err !== null) {
        callback('Insertion failed.');
    } else {
        callback(null);
});

Is there a way to circumvent this problem using the sqlite3 module?

Thanks in advance.

2

1 Answer 1

1

Could you just use async.queue?

var async = require('async');

var q = async.queue(function(task, callback) {
    db.exec(task.query, function(err) {
        callback('Insertion failed.');
    });
    callback();
}, 1);

q.drain = function() {
    console.log('queue is empty, ready for more query');
};

q.push({query: "Your SQL INSERT query"}, function(err) {
    console.error(err);
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.