Gossamer Forum
Quote Reply
Importing script
Hi

I Have someone who is interested in using my current Links SQL database on another site that uses Links 2.
I know that importing from Links 2 ----> links SQL is easy.
But How about a reverse import from Links SQL ---> links 2?
Can it be done and how to do it ?
If anyone can write an import script that will do that how much will it cost? I think it is a change in the Links SQL current import script logic..!



Regards
Abd

http://www.idleb.com
Quote Reply
Re: Importing script In reply to
Links 2.0 Flat file uses a different structure than Links SQL 2.x

First, the links in 2.0 contain the directory/category information. In Links 2.x they do not.

You would need to select out the Links records, adding in the category record, then writing out the fields in order of the Links 2.0 flatfile definitions file.

At the same time, you'd need to create a list of the categories, and create a category file that would match the definitions of the category structure.

You could use hashes to store the data, but you'd have to write it out in order, so an array or using explicitly named variable output would be needed.

If this is being imported into a new Links 2.0 flat file installation, it would not be as tricky as if it was trying to be merged into an existing one.

Depending on how large your databse was, you could do a simple select ID from Links order by ID to select out the set of links, even 20,000 links shouldn't be too much to select out 20,000 integers (I might be wrong though). Then just work through that to write out all your links.

If you have a really large database, you'd have to do it differently, using a place holder, and LIMITing your selects. (of course you could also do brute force, starting at 1 and just iterating by +1 up to the value of SELECT ID FROM Links ORDER BY ID DESC LIMIT 1 Just test to see if each "id" exists, if not, add one, and try again [or using Links methods: ($rec=$db->get($id)) or next;]

I won't say this is a "trivial" application (since I don't exactly remember the category table in Links 2.0 flat file) but it's darn close to being one. This is the sort of disposable script PERL was made for :)



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: Importing script In reply to
Wow
You Have Just made my eve nicer...:)
I knew It will not be that easy but I have a client who is welling to pay for such a project in the form of a script that does it all...
I though it will be very hard to do so.. But it never hurt to try the experts and see what they think
thanks

Regards
Abd

http://www.idleb.com