Jump to content

The ultimate community for Ruby on Rails developers.


Getting the following message when attempting to update database - "SQLite3::BusyException: database is locked"

  • Please log in to reply
2 replies to this topic

#1 ExNihil



  • Members
  • 7 posts

Posted 15 September 2013 - 03:28 PM

I'm working through Rails Tutorial and seem to be stuck by an error occurring at listing 6.20 within chapter six (http://ruby.railstut...odeling-users):[1]


class User < ActiveRecord::Base

before_save { self.email = email.downcase }





This flat-out does not work. The before_save is causing an error that reads: SQLite3::BusyException: database is locked: INSERT INTO "users" ("created_at", "email", "name", "updated_at") VALUES (?, ?, ?, ?)

Even when I remove the before_save from my User model, the error remains.

Does anyone know precisely why this is happening and how I can fix it?

#2 james



  • Members
  • 223 posts
  • LocationLeeds, U.K.

Posted 15 September 2013 - 04:48 PM

Welcome to the forum and welcome to Rails.

Firstly, this is extremely unlikely to be an issue with your code although you should check to see if you have any transactions that have not been finalised/commited, again, unlikely but possible.


SQLite does not support concurrent access. This is not normally an issue when developing so I can only think that some process is holding a lock on it. Perhaps you have a some other application browsing your database, Some sqlite database tool?


If you are not certain what is locking the db then re-boot your PC, delete the lock file and try again.


This is an extremely rare occurrence.

  • ExNihil likes this
Programming is just about problem solving!

#3 ExNihil



  • Members
  • 7 posts

Posted 15 September 2013 - 10:53 PM

Thanks for the help and the welcome, James.  I think the core issue was that SQLite Database Browser was running while I ran the command. As per your suggestion, closing it seems to have fixed the issue.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users