[Digikam-users] SQLITE INSERT

Duncan Hill digikam at nacnud.force9.co.uk
Mon Apr 30 06:29:37 BST 2007


Andy Choens wrote:

> I need to insert the appropriate imageid and tag id into ImageTags. As I 
> understand SQL that is as simple as:
> 
> INSERT INTO "ImageTags" VALUES(443,150);
> 
> But, I need to be able to match the imageid in ImageTags to specific values of 
> dirid and name. I would like to make a statement along the lines of.
> 
> INSERT INTO ImageTags VALUES(Images.id, 1)
> WHERE (Images.dirid = '2003/') AND (Images.name='dscn1234.jpg');

Really and truly, I should only answer this question with a copy of the 
digikam DB in front of me.  Unfortunately, it's on a dying drive, and 
that drive has been off-lined until I can get the data archived off.

On the assumption that Images looks like:
Images.id int
Images.dirid string
Images.name string

and Image.id auto-increments when a dirid+name is inserted

and that ImageTags looks like:
ImageTags.id int
ImageTags.tagid int

and that neither of those values increments automatically, but instead 
ImageTags serves as a joining table for Images and Tags, then your 
443,150 insertion is correct without any additional parameters.  443 
already uniquely identifies the image that is being tagged.



More information about the Digikam-users mailing list