Digikam does not start ? Do not drop your database (yet) ! It may be fixed.

Here is a post to give some hope to Digikam users in trouble with their metadata database.

Under some tricky conditions, Digikam may « corrupt » its SQLite database and then refuse to start with such messages:
$ digikam
QSqlDatabasePrivate::removeDatabase: connection 'ConnectionTest' is still in use, all queries will cease to work.
QPainter::end: Painter ended with 2 saved states

That ConnectionTest message may be normal and expected. But the error window displays more valuable information:

The schema updating process from version 4 to 5 failed, caused by an error that we did not expect. You can try to discard your old database and start with an empty one. (In this case, please move the database files « digikam3.db » and « digikam4.db » from the directory « /home/yma/Pictures »). More probably you will want to report this error to the digikam-devel@kde.org mailing list. As well, please have a look at what digiKam prints on the console.

In my case, I am aware of what went wrong: I have started two Digikam processes almost in the same second and I have decided to kill them both because of my CPU at 100%. Then it denies to start again.

Browsing for a solution in forum leads to the definite action: delete the database and restart from scratch. That was not satisfying for me, my last database re-init was three years ago and my fear to loose my tag indexing makes me investigate.

Based on this SQLite how-to, I have first checked that the SQLite database itself is not « corrupted ». Run the integrity checking and try to export its content:
$ sqlite3 digikam4.db
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> pragma integrity_check;

$ echo .dump | sqlite3 digikam4.db > archive-digikam4.sql

That operations have passed successfully, there is hope. At least I have a complete or partial backup in SQL format.

Using SQLite browser, I have simply discovered that the DBVersion row in table Settings has the value 0 instead of the expected 5 version, which is consistent with the error message displayed.

Then the fix: set 5 instead of 0 there, save the database and restart Digikam. Here it is !

Now I am pleased to have found the way to get my Digikam database back… and I hope this post may help anyone with the same trouble or something close to get his issue fixed.

2 commentaires

  1. Thanks a lot for this great tip!
    I got the link to your page from the Digikam users mailing-list.

    As I am running Fedora, I just had to install sqliteman from the repository, launch it from the Gnome menu, and update the DBVersion record according to your explanations.

  2. Thanks as well for the tip! It has worked for me. This is how I did it in Kubuntu:

    sudo apt-get install sqlite3

    sqlite3 digikam4.db

    sqlite> update settings set value=5 where keyword=’DBVersion’;

    And that’s it. This way you don’t even need the SQLite Browser.

Laisser un commentaire