‘Repair’ your F-Spot database with Libgda

Continuing to work around the idea of virtual connections and virtual tables in Libgda (which allow to run SQL commands on data coming from databases but also from data models) I have written a small tool to repair an F-Spot database.

The “repair” term is a bit awkard since the aim of the tool is to correct the path of some pictures in your F-Spot database after you have moved them to another directory. For example if I had some of my pictures in /my/pics/dir and moved those to /another/dir then I can run:
repair-path /another/dir
and the paths will be corrected for the files which have a unique file name in /another/dir.
The tool is far from being featurefull as it for example will look only for unique file names in resolution, but it’s just an example.

Internally a connection is opened to the F-Spot database (an SQLite file), a data model is created which lists the files in /another/dir and a virtual connection is created which imports the tables from the SQLite connection using the spot namespace, and shows the files table as the contents of the data model, as shown in the following diagram:

Connections setupSQL commands are then issued to the virtual connection to determine missing images and the possible corrections.

The code requires SVN trunk’s Libgda version and can be found in the http://svn.gnome.org/viewcvs/libgda/trunk/samples/F-Spot
directory. Make sure to read the README file for more information.

Leave a Reply

Your email address will not be published. Required fields are marked *