Digikam Database Validator

 

As you may have read in the Tools I use section, all my images are managed in Digikam.
I’ve been using it for several years, upgrading versions as they were released and at the time of writing this, I have about 40,000 images in its database.

Since a few releases, Digikam has introduced support of MySQL as a backend as an alternative to the SQLite embedded database. Digikam provides a migration wizard to switch from SQLite to MySQL but for some reason, I have never been able to successfully perform the migration and am still using SQLite.

This lead me to thinking that my Digikam database might have become inconsistent after having moved around so many images and thought it would be a good idea to write a tool to inspect the thousands of records in the database’s tables and figure out if they all make sense, if some might be missing, if some might be orphaned.

While all my other tools were written in bash, the complexity of this challenge made me chose Java. For you, it will be just as easy to use. No parameters are required as the tool will figure out the location of your Digikam database.

usage: java -jar DigikamDBValidator.jar
Digikam DB Validator
Report bugs to <photo@tassy.net>Database Schema version is 5 – All tables will be validatedChecking AlbumRoots…OK
Checking Albums…OK
Checking Image Comments…OK
Checking Image Copyrights…OK
Checking Image Hashes…OK
Checking Image Informations…OK
Checking Image Metadata…OK
Checking Image Positions…OK
Checking Image Properties…OK
Checking Image Tags…OK
Checking Images…OK
Checking Tags…OK
Building Tag Tree…OK
Checking TagsTree for completeness…OK
Checking TagsTree for orphaned entries…OKNo error found – Your Digikam database is integer

In this example, no errors were identified in the database and hopefully, that’s what you’ll get !

In my case, in the “Checking Images” item, the tool returned with 259 errors of the following type:

Image 32906 points to inexistiant Album 750
Image 33342 points to inexistiant Album 814 but similar image also found in album 1490

My guess is that there may have been a bug in one of the older versions of Digikam and when I had moved images to different albums, deleted albums or what not, some records in the database were not updated accordingly.

After looking at the entries in question, it seems those are all referring to some older pictures in my collection and none of these problems are recent so I’m confident that this was a bug that was fixed a while ago.

So what to do if the tool comes back with some errors ?!

Well, the tool won’t fix the database for you. This is something you’ll have to do manually … You can use the sqlite3 command line utility and issue SQL statements to look at the incriminated records and fix/delete them or you can use a graphical user interface like the SQLite Manager plugin for Firefox that I find very convenient !

Notes:
At the moment this tool only support the SQLite backend, not MySQL. I’ll add MySQL support shortly.
Since I have not yet upgraded to Digikam 2.0, the tool only looks at the tables existing today in 1.9. All the new tables added with 2.0 are not analyzed. I’ll also add support for this soon.

The latest version of the tool and sources can be downloaded from the attachments section at the left of this page !

If you like this script, feel free to leave a comment !

If you run into problems, you can send me an email at photo@tassy.net and I’ll help you out.

CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

  6 Responses to “Digikam Database Validator”

  1. >> “Your Digikam database is integer”

    I’m not sure what you mean by that, don’t you mean something like “You Digikam database is correct” or “… is valid”

    A database “being integer” doesn’t make any sense in English

    • Hi Mark, thanks for the feedback; someone pointed it out to me already ๐Ÿ˜‰
      It’s my mistake … bad translation from French ๐Ÿ˜‰ Comes from “integrity”
      I’ve fixed it in the upcoming release

  2. Thanks for this script, it’s very useful. It’s a shame Digikam can’t sort out its own problems though!

  3. Thanks for this! I didn’t try your script since it’s an old post, but I didn’t know about the SQLite Manager plugin which still works! Browsing my Digikam database let me quickly see that the tags were lost from my latest, and that the backup had them. Now I’m migrated to Digikam 5.

    • Glad it helped one way or another ๐Ÿ˜‰
      Digikam now has its own Database Maintenance tool so no real need for me to maintain this piece … that was the early days …
      Cheers !

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>