admin管理员组

文章数量:1244247

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');
});

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');
});
Share Improve this question edited Nov 3, 2015 at 16:32 jhlosin asked Nov 3, 2015 at 8:18 jhlosinjhlosin 5752 gold badges7 silver badges17 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 14

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.

Also works, when you kill the running port.

For ubuntu Use:

'sudo kill -9 `sudo lsof -t -i:<POOR_NUMBER>`'

本文标签: sqlitejavascript SQLITEBUSY database is lockedsql insert into quotusersquotStack Overflow