in reply to Re: mySQL Times Out / Disconnects
in thread mySQL Times Out / Disconnects

That missing curly must be a type on this page, but I'm not getting those kind of errors.

I'm not sure what you mean by placeholders...?

My Execute sub is either one of two below, I just thought it would be self explanatory:

sub Execute { if ($_[1] == 1) { $sth = $dbh->prepare( $_[0] ) || &Terminate('Sorry, not Preparing'); $sth->execute || &Terminate('Not Executing'); } else { $dbh->do( $_[0] ) || &Terminate('No Do'); warn( $DBI::errstr ) if ( $DBI::err ); $rc=$dbh->disconnect(); }

I need to compare SSN to make sure there are no typos on either the CSV or DB tables. There are over 16K members and I actually intend to log the errors found.

And Yes, the CSV is definitely all Uppercase (I don't know why).

I used the Delay and Low_Priority when I started giving up and trying other things, unfortunately, I don't see a difference... just left it in since then.

I was considering the Load Data Local Infile things, but realized my limitation when I needed to compare stuff before the Inserting/Updating happens.

Replies are listed 'Best First'.
Re^3: mySQL Times Out / Disconnects
by graff (Chancellor) on Oct 03, 2007 at 13:20 UTC
    I'm not sure what you mean by placeholders...?

    Search for that term in the DBI manual, read carefully to understand all the ways they can make your code better, and work it into your code. Basically, you create a query string with one or more question mark characters where a value would be -- each question mark is a "placeholder" for a value. Then you do $sth=$dbh->prepare($statement) in the normal way, and when you execute it, you pass values for each placeholder: $sth->execute(@values) (or $sth->execute($val1,$val2,...)), as shown in the code I posted above.

    I was considering the Load Data Local Infile things, but realized my limitation when I needed to compare stuff before the Inserting/Updating happens.

    I'm not understanding what your "limitation" is. You just open an output file before the loop; within the loop, instead of executing an insert statement, you print a line to the file; after the loop you close the file and execute a "LOAD DATA LOCAL INFILE ..." statement. You can't use this approach for the updates -- those still need to be executed on each loop iteration.

    (updated to improve grammar)