I am working on a 'sign up' page and having trouble with sqlite.
I am using express, bcrypt-nodejs, bookself.js for sqlite. getting an error saying database is lock. any workaround for this? appreciated. below is the code for the part.
app.post('/signup', function(req, res){
var username = req.body.username;
var password = req.body.password;
bcrypt.hash(password, null, null, function(err, hash){
new User({'username': username, 'password': hash})
.save()
.then(function(){
console.log('Successfully added a user');
})
.catch(function(err){
throw err;
});
});
res.render('login');
});
The problem was that you have the ".sqlite" file opened by other editors or SQLite Clients while interacting with SQLite programmatically.
Make sure the .sqlite file is not opened/used by any other application before running/testing your code.