Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Links 1.11: Importing ID Numbers

Quote Reply
Links 1.11: Importing ID Numbers
Hello there.

I have searched the forums for the past week and also read through most of the FAQs at pugdog's great FAQ site, and I know this has been discussed before...but I can't find the Thread that provides solutions....

How can I import exact IDs from links.db into the Links table?

I have tried the following:

1) Renamed ID in the links.def file to LinkID. Then I added the following codes in the Import.pl file in the INSERT LINKS section:

Code:

$values{'ID'} = $values{'LinkID'};


2) I also tried turning off the $db_track variable for Importing.

The IDs are compressed and I lose the exact IDs in the links.db file.

Not a huge problem...but for features like the External Rate It and modifying links, it will cause confusion for Link Owners.

Please provide the Thread that provides a solution to this problem.

TIA.

Regards,

Eliot

Quote Reply
Re: Links 1.11: Importing ID Numbers In reply to
There is no simple way.

The problem is that the "addlink" routine is set to _not_ accept an ID number, since it will automatically assign one. I think early on (like 6 months ago) Alex said he was looking at making the routines more general.

One way would be to add a field to the imported database that would hold the value of the LinkID in an extra field.

once the database was imported, you'd run an SQL query to SET ID=LinkID. There is a caveat with that, and you might have to do something like multiply the LinkID by 10,000, make the assignment, then go through and divide by 10,000, export the database, and empty the table, and re-import it.

The only other way for an initial import from an unmatched database would be to go into the Import.pl file, and edit the "add" routine to a simple "insert" which will allow you to set all field parameters. You lose some error checking that way, but if you do the assignment carefully, it should work.



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Links 1.11: Importing ID Numbers In reply to
Thanks, pugdog...I thought there was an easier solution posted awhile back...oh well...I will give it a shot.

Thank! Wink

Regards,

Eliot

Quote Reply
Re: Links 1.11: Importing ID Numbers In reply to
there was an easier solution, but not for this sort of import.

The problem is that from Links 2.0 to Links 1.11 there is a change in the database record for the link.

the SQL database uses only the Category ID to locate the link, not the category name.

So, if you tried to just directly import the links, you'd get an error because the Category ID is an integer, and in links 2.0 it's text.

If your categories are already installed, and the names are not different, you could write a fairly small program to read your links 2.0 database file line by line,pop the values into the hash,change the CategoryName field to CategoryID doing a look-up on the category table by Name and yanking out the ID, then "INSERT"ing this record into the Links table, not using the "addrec" routines of DBSQL.pm.

If you get a bad category name lookup, then insert the link into the Validate table... but you might want to make a copy of the validate table, and insert the bad links into a table called Validate2 --- just in case there are a LOTof them!! If there are a few, you can copy them from the validate2 table to Validate and edit them to new categories.

Make sense?

The problem is the way Links 2.0 held "CategoryName" and Links SQL holds "CategoryID"



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/