Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi perl monks,
i worked mysql version 5.0.16 and perl version 5.6.1(Net::Mysql-0.04) it gonig smooth. now my mysql server changed with 5.0.27 working with perl 5.6.1(Net::Mysql-0.09). it is retiving some table data .But some few table it is hanging those tables not having much data also even i tested in the server same tables with same query working fine. here is my code
use Net::MySQL; our $mysql = Net::MySQL->new( hostname => "$Hostip", database => 'DB', user => 'test123', password => 'test123' ); my (@value) = selectRecord('MASTER','USER_NAME',"USER_ID = 'test' AND +DELETED=0"); print "@value\n"; sub selectRecord { my($TableName,$FieldName,$Condition)=@_; my(@Result); $mysql->query(qq{SELECT $FieldName from $TableName where $Conditio +n}); if ($mysql->is_error) { my $DBError = $mysql->get_error_message; print "$DBError\n"; return(0); } else { my $RecordSet = $mysql->create_record_iterator; while (my $Field = $RecordSet->each) { push(@Result ,$Field->[0]); } } #Sorting arrays @Result = sort {uc($a) cmp uc($b)} @Result; return(@Result); } $mysql->close;

Replies are listed 'Best First'.
Re: probelm with Net::MySQL
by Krambambuli (Curate) on May 11, 2007 at 09:08 UTC
    Try to use a different constructor, for activating debug and increasing/playing with timeout, like
    our $mysql = Net::MySQL->new( hostname => "$Hostip", database => 'DB', user => 'test123', password => 'test123', debug => 1, timeout => 120, # seconds );
Re: probelm with Net::MySQL
by Anonymous Monk on Aug 12, 2007 at 15:05 UTC
    Hello, Did anyone have a solution for this issue? I'm using Net::MySQL 0.09 also and have the same problem. Whenever I use the primary key in a where clause the query hangs. (This worked fine in Net::MySQL 0.08) When I run the query directly against the DB it runs fast as well. Any suggestions?
Re: probelm with Net::MySQL
by chrism01 (Friar) on May 14, 2007 at 05:00 UTC
    I must admit it's the first time I've heard of Net::MySQL.
    I've always found that DBI plus DBD::mysql works just fine for local and remote DBs (also multiple DB handles in the same program).
    Maybe you should try them (if you get stuck)??

    Cheers
    Chris