javascript SQLITE_BUSY: database is locked, sql: insert into “users”

China☆狼群 提交于 2019-12-13 01:01:43

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/33494304/javascript-sqlite-busy-database-is-locked-sql-insert-into-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!