dartable library.db keyword question

I am trying to import Adobe Lightroom keywords into darktable and would like to do that by inserting rows in data.tags and library.tagged_images tables (I don’t want to mess with xmp sidecar files).

This seems to be straightforward but I am not sure I understand the purpose of the column tagged_images.position and even less why it is calculated as follow (according to src.common/tags.c):

SELECT (IFNULL(MAX(position),0) & 0xFFFFFFFF00000000) + (1 << 32)"
         "    FROM main.tagged_images

Anyone could shed light on that?

For reference, here is the query I am using to extract the image/keyword from Lightroom:

SELECT                    
	  upper(root_folder.name || '/' || folder.pathFromRoot || file.baseName || '.' || file.extension) as file_name,
	  keyword_ref.name as keyword
	from
	  AgLibraryFile AS file
	inner JOIN AgLibraryFolder AS folder
	  ON folder.id_local = file.folder
	inner JOIN AgLibraryRootFolder AS root_folder
	  ON root_folder.id_local = folder.rootFolder
	inner JOIN Adobe_images AS image
	  ON file.id_local = image.rootFile
	inner JOIN AgLibraryKeywordImage AS keyword
	  ON keyword.image = image.id_local
	inner JOIN AgLibraryKeyword AS keyword_ref
	  ON keyword_ref.id_local = keyword.tag

If you can export your lightroom keywords you can import it
See darktable 4.6 user manual - tagging

Hi Martin,

What I am trying to do is not just to import tags (which indeed can be done using the darktable import tag feature - although see my note below) but also assign them to the images, just like they are in Lightroom. As far as I know, darktable doesn’t provide a tool for that.

On a side note: the import tag of darktable adds double quotes to tags that are made of multiple words. For instance, the tag Snowy Day becomes “Snowy Day”.

My understanding is that when you import an image with the light room XMP file, it adds the tags to the images.

Hi Mika, thank for chiming in.

It does, but as I mentioned in my original post, I don’t want to mess with xmp files as I have hundred of thousands of images in Lighroom already imported in darktable.

Since I only have simple tags (no hierarchy, no synonym) I will try to migrate my keywords/tags using sqlite and python. I was just wondering what this “position” column was about rather than blindly populate it without knowing its purpose.