Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Import problems: L2S2.pm to Links SQL v2.0.5

Quote Reply
Import problems: L2S2.pm to Links SQL v2.0.5
Hello Alex!

The seems to be something not working.

I tried to use L2S2 import module to get ASCII to SQL format. For this I installed a default Links v2.01 and it is working correct. No problems.

Giving the defs location of Links v2.01 in the Links SQL 2.0.5 and tring to import couple of categories and couple of links (Default) it has some problems.

It does only one link import per category!!! So if there are more links it generates errors and checking the code, it shows following trouble area.



if ($bad_cats == @cat_ids) { # Between the category and the alternate categories, there has to be at least ONE good one.

if (@cat_ids == 1) {
warning "Invalid category `$cat_ids[0]' for link $$row[0] (ID: $id, line $.). Link skipped";
next LINK;
}
else {
warning "No valid categories ($cat_name @category_alternates) for link $$row[0] (ID: $id, line $.). Link skipped";
next LINK;
}
}

Lets say there is a link in a Category "Europe". It will therefore create one category Europe. Then if there is anathor link in Europe it may work that it gets inserted.

However, the import was broken and I tried to import it again. So without any option clicked, it skipped the categories saying that there are duplicates. But when it came to importing links it did not. Because it tried to create categories from the lines of the links.db and having found it in there, it gives an error.

-------------------------

What I want is that I would like to import from Access or excel format into SQL format. This is only possible through ASCII imports. For this I have Category.db and Links.db. I can also create some more dbs if necessary like email.db, etc to fill in correct information.

I could create the correct defs files for them. Hence it would be no problem to import then if there are some minor changes of L2S2.pm module. Then it can work perfect.

I would very much appriciate if you could help.




Last edited by:

rajani: Nov 26, 2001, 7:17 AM
Quote Reply
Re: [rajani] Import problems: L2S2.pm to Links SQL v2.0.5 In reply to
Hello Alex1

By removing the above code, it does insert the links. However it fails to make the Links ID + Category ID in the table CatLinks. The error is:

Importing Links ...
WARNING: Unable to execute query `INSERT INTO Table_CatLinks (LinkID, CategoryID) VALUES (?, ?)': Column 'CategoryID' cannot be null


This is due to the following code in L2S2.pm

if ($insert_link_sth->execute($id,$username,'Yes',$date,$date,@$row)) {
for my $cat_id (@cat_ids) {

$cat_links_sth->execute($id,$cat_id) or warning "Unable to execute query `INSERT INTO ${e_prefix}CatLinks (LinkID, CategoryID) VALUES (?, ?)': ".$cat_links_sth->errstr;
$num_of_links[$cat_id]++;

}
import_print "$links_imported\n" unless ++$links_imported % 500;
}


Here the info of $cat_id disappears. If it is possible to capture it again, then it solves the problem.

What interesting would be to make a script to use for the ASCII imports.

Any ideas?

Thanks
Quote Reply
Re: [rajani] Import problems: L2S2.pm to Links SQL v2.0.5 In reply to
Hello!

I need help to get the Category ID and insert them into Catlinks. The most likely area would be the following code in the L2S2.pm

------------existing-----------

else {
mild_warning("Not enough information to add a user for link `".($$row[0] or '<unknown>')." (URL: ".($$row[1] or "<none>")."). Setting link owner to `admin'");
$username = 'admin';
}
------------existing-----------

if ($insert_link_sth->execute($id,$username,'Yes',$date,$date,@$row)) {
for my $cat_id (@cat_ids) {

for (@cat_ids) {
my ($father_full) = m[\A(.*)/];
my $father_id;
if ($father_full) {

$get_cat_id_sth->execute($father_full) or critical "Unable to execute query `SELECT ID FROM ${e_prefix}Category WHERE Full_Name = ?': ".$get_cat_id_sth->errstr;

$father_id = $get_cat_id_sth->fetchrow_array;
}

my $cat_links_sth = $e_dbh->prepare("INSERT INTO ${e_prefix}CatLinks (LinkID, CategoryID) VALUES (?, ?)") or critical("Unable to prepare query `INSERT INTO ${e_prefix}CatLinks (LinkID, CategoryID) VALUES (?, ?)': ".$e_dbh->errstr);

$cat_links_sth->execute($id,$cat_id) or warning "Unable to execute query of xxx `INSERT INTO ${e_prefix}CatLinks (LinkID, CategoryID) VALUES (?, ?)': ".$cat_links_sth->errstr;

$num_of_links[$cat_id]++;
}
}


What it needs to do is to

- make a query in the table and return the Category ID and Father ID.

- This needs to be equal to the Category of the link being imported.

- Insert into the CatLinks table.

Any ideas?

Last edited by:

rajani: Nov 26, 2001, 9:52 AM