[MOBY-dev] Perl API: MOBY::Central::DUMP_MySQL()

Pieter Neerincx Pieter.Neerincx at wur.nl
Wed Jul 6 14:50:42 UTC 2005


Hi all,

This message is for those who use Perl and have local MOBY Centrals.  
I had some problems with the way MOBY::Central::DUMP_MySQL()  
currently works. Getting a DUMP fails for example with the new  
central at:

URL: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl
URI: http://mobycentral.icapture.ubc.ca/MOBY/Central

Currently DUMP_MySQL() has the mysql username, the path to mysqldump  
and the lack of a password, host and portnumber hard coded. Hence it  
ignores whatever you have in your mobycentral.config file. Therefore  
I propose the code below which uses MOBY::Config->new() to get the  
connection details from your mobycentral.config. The path to  
mysqldump is no longer hard coded. Hence if it's not in the path of  
webserver user, I think it's better to modify the path env var as  
compared to hard coding it in the perl modules:) Unless anyone has  
objections against the porposed code I'll merge this with the code in  
the CVS in a few days...

Cheers,

Pieter

--------------------------------------------------
sub DUMP_MySQL {
         my ( $pkg ) = @_;
         my $config = MOBY::Config->new();
         my @dbsections = ('mobycentral', 'mobyobject',  
'mobyservice', 'mobynamespace', 'mobyrelationship');
         my @response;

         foreach my $dbsection (@dbsections)     {
                 my $dbname   = ${${$config}{$dbsection}}{'dbname'};
                 my $username = ${${$config}{$dbsection}}{'username'};
                 my $password = ${${$config}{$dbsection}}{'password'};
                 my $host     = ${${$config}{$dbsection}}{'url'};
                 my $port     = ${${$config}{$dbsection}}{'port'};
                 open( IN, "mysqldump -h $host -P $port -u $username  
--password=$password $dbname|" )
                         || die "can't open $dbname for dumping";
                 my @dbdump;
                 while ( <IN> ) {
                         push @dbdump, $_;
                 }
                 my $dbdump = ( join "", @dbdump );
                 push @response, $dbdump;
         }
         return [@response];
}
------------------------------------------------



Wageningen University and Research centre (WUR)
Laboratory of Bioinformatics
Transitorium (building 312) room 1038
Dreijenlaan 3
6703 HA Wageningen
phone: 0317-484 706
fax: 0317-483 584
mobile: 06-143 66 783
pieter.neerincx at wur.nl





More information about the MOBY-dev mailing list