0

I read all post as possible on the web (and not only in this wonderfull forum), I use SQLite from 5years ago now, and I still this "bug" (I don't known how named it) : SQLSTATE[HY000] [14]

  • Yes my folder is writeable
  • Yes ths sqlite file is wirteable
  • Yes user AND group is set to www-data (server user)
  • Yes I've setup sqlite and use it on the same server (so is NOT a config problem)

So what is going on?

ls :

user@host:/folder/where/is/the/site$ ls -lha db_folder/
total 36K
drwxrwxr-x 3 www-data www-data 4.0K May 10 06:15 .
drwxr-xr-x 3 www-data www-data 4.0K May 10 06:34 ..
-rwxrwxrwx 1 www-data www-data  36K May 10 05:22 db.sqlite

Thanks in advance.

EDIT: my php code even if it's not very specifique to me :

$db = new PDO('sqlite:dbname=./db_folder/db_file.sqlite', '', '', array(PDO::ATTR_PERSISTENT => true));
$articles = $db->query('SELECT * FROM articles ORDER BY name')->fetchAll();
Chenille33
  • 93
  • 1
  • 1
  • 10
  • 2
    Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) or [Database Administrators Stack Exchange](http://dba.stackexchange.com/) would be a better place to ask. – jww May 10 '18 at 11:22
  • Is it possible that there is still another SQLite process running somewhere (or some other process) which still has a handle on the database file? You've made it `rwx` by everyone, so permissions should no longer be an issue (by the way, you probably won't want to do that in production). – Tim Biegeleisen May 10 '18 at 11:24
  • Of course is not a production config, I try just to make works sqlite :) But I don't think annother instance is lauched, I upload it now and trying just after.... – Chenille33 May 10 '18 at 11:40
  • 1
    The code might be doing something wrong. But nobody can know as long as you keep it secret. – CL. May 10 '18 at 13:31
  • My code is realy simple: a new PDO object. Even if I exit just after creating object, I've this error.... – Chenille33 May 10 '18 at 16:19

1 Answers1

-1

The sqlite file gets locked when a process is writing to it. See sqlite documentation about this here.

The RESERVED lock signals that the process intends to write to the database at some point in the future. Only one process at a time can hold a RESERVED lock

Try closing the sqlite database after the write, since your script might be trying to re-open an already open sqlite file every time it's run.

  • Thanks for these precisions. But I still don't understand why in my code why db is locked... I just make a basic new PDO object and it's on local server so nobody use it and I don't open it with a "sqlite browser" or other.... – Chenille33 May 10 '18 at 16:22
  • because the next time php tires to open the sqlite db its can't because it was already opened. You have to close the sqlite db file at the end of your script. https://stackoverflow.com/questions/18277233/pdo-closing-connection – Rambarun Komaljeet May 22 '18 at 14:13