Search code examples
phpsqlitepdo

Sqlite3: display error Database is locked


My sqlite3 database display this error:

Array (
  [0] => HY000
  [1] => 5
  [2] => "database is locked"
)

I have used php PDO for connect sqllite3 database.I have successfully read from database but cannot update/insert into database. It is always shows above error.

I have tried 777 rights to database and also test with it but got the same result.

I have solved above problem using $db->beginTransaction(); and $dbhandle->commit();

Now problem is that I have used begintransaction before update query and commit after execute the query.Query return true every time but does not affect in database. any idea about it ?

Note: Query took long time to display error.


Solution

  • I have solved my problem.

    Problem in sqlite3 database.I have used sqlite3 3.6.22 on Ubuntu 10.04, This sqlite3 does not support multithreading so I have tested on sqlite3 3.7.7 version and use Pragma command read from http://www.sqlite.org/wal.html.