5

Platform: Firefox 3.6.13, Python 2.7 stackless, and Windows 7 (not yet tested on Ubuntu, I will...)

I tried with the apsw library:

conn = apsw.Connection( dir + profile + '/places.sqlite', apsw.SQLITE_OPEN_READONLY )

And I got the error:

File "c:\apsw\src\statementcache.c", line 386, in sqlite3_prepare apsw.BusyError: BusyError: database is locked

I see "SQLite manager" can open the database also with Firefox running.

I just want to open and read, I think a trouble free operation. And I cannot use "SQLite manager". I need to code my Python (or PHP or Perl) script.

1) Which type of lock does Firefox use on the SQLite file? Why?

2) How does "SQLite manager" work?


Q2) SQLite Manager works in JavaScript, inside Firefox, so it can access the database.

This is not what I am looking for: An external application reading places while Firefox is running.

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Massimo
  • 3,171
  • 3
  • 28
  • 41

2 Answers2

8

I am not sure about the lock type Firefox uses, but I'd recommend this:

Copy the Firefox database file to a different temporary location and read it from there (this also lowers the risk of accidentally damaging the original file).

I haven't had problems with this method yet on Firefox 3.*.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Amos
  • 1,403
  • 2
  • 13
  • 19
  • 2
    BTW, I've recently had problems with opening the places.sqlite of Firefox 4. It seems like reading it requires SQLite 3.7 which is not integrated into all 3rd party language wrappers yet (older versions get a "db is encrypted" error). So keep an eye out for this problem, too. – Amos Jan 26 '11 at 12:22
  • Thanks to your hint I got sqlite 3.7 running with Firefox 4.0 places.sqlite. But I'm looking for the ADO.NET solution and sqlite-dotnet-x86-1006900.exe doesn't work with PowerShell (possibly a debug build) – bernd_k Apr 22 '11 at 17:54
  • i am finding that when it try read from the database (d copied history), sometimes it is not updated.. :/ it seems to remain locked – michelle Apr 26 '11 at 21:35
5

Firefox uses SQLite to obtain an EXCLUSIVE lock on the database, which is why you cannot open it: https://www.sqlite.org/pragma.html#pragma_locking_mode

sdwilsh
  • 4,674
  • 1
  • 22
  • 20