mp has asked for the wisdom of the Perl Monks concerning the following question:
The output while the server is down looks like:my ($user, $password, $dsn); ### Set these to run code my $sql = "select * from tablename where id=?"; use strict; use warnings; use DBI; my $dbh = DBI->connect($dsn, $user, $password, {RaiseError => 1}); my $sth = $dbh->prepare($sql); my $result; for(1..1000) { eval { $result = &simple_query; }; if ($@) { print "Found error [$@]\n"; } else { use Data::Dumper; warn Dumper($result); } sleep 1; } sub simple_query { $sth->execute(int(rand(7000))); my $ref = $sth->fetchrow_hashref or return; return $ref; }
DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at ./db_connect line 31. Found error DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at ./db_connect line 31.The output when it comes back up looks like normal Data::Dumper results from a hash.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI connection springs back to life - how?
by pope (Friar) on Jul 26, 2002 at 03:48 UTC | |
by mp (Deacon) on Jul 26, 2002 at 15:18 UTC |