I'm trying to read and update and insert items all from a CSV file I'm reading from, but the process stops after ~450-490 changes are made. I have 5,000+ records and I've even removed the top 400 to see if it was possibly a bad character/field, but still I get the same failing results. I'm not sure if the Database has a time limit for connections or a limit on processes (which I doubt). I've used print $dbh->{mysql_error}, br, $dbh->{mysql_errno} during the Terminate sub call within the Execute and SQL subroutines, but I get 0, which supposedly means all is good, but the program ends early and says I've been disconnected. Here's my the main subroutine:
use Text::CSV::Simple; my $parser = Text::CSV::Simple->new; $parser->want_fields(0, 1, 2, 4); my @CSV_File = $parser->read_file($_[0]); &SQL('connect'); for my $row(@CSV_File) { my @CSV_Row = @$row; my ($FN, $LN, $SSN, $Title) = @CSV_Row; my ($do1, $do2); $Check="SELECT id, lastname, firstname, ssn FROM member WHERE UPPER(lastname) = '$LN' AND UPPER(firstname) = '$FN')"; # Find m +atching member &Execute($Check, 1); while (my ($id, $ln, $fn, $sn)=$sth->fetchrow_array()) { $do1="INSERT DELAYED INTO reports (lastname, firstname, title, ID) VALUES ('$ln', '$fn', '$Title', '$id')"; $do2="UPDATE LOW_PRIORITY member SET working = 'Y' WHERE (ID = '$id') LIMIT 1"; if ($SSN ne $sn) { &LogEvent("Fail SSN: $SSN for $id"); # Compare SSN +for exact match } else { &Execute($do1); &Execute($do2); } &LogEvent("Success"); } # END WHILE sub SQL { $dbh = DBI->connect("DBI:mysql:DBname","$un","$pw") || Terminate('Sorry, Disconnecting'); # Prints error . $_[0] } # END SQL 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(); } # END Execute
Thanks in advance for your help.

In reply to mySQL Times Out / Disconnects by JayBee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.