[Bioperl-l] DBI connection parameters

Hilmar Lapp hlapp at gmx.net
Fri Aug 26 16:37:26 EDT 2005


On Aug 25, 2005, at 2:36 PM, Amit Indap wrote:

> [...]  But its having trouble connecting to my mysql db when I call
> my $dbseq= $adp->find_by_unique_key($seq);
> (where $seq holds my Bio::Seq object to which I want to add features
> to) The stack is listed at the end of the msg.
>

The stack says:

> MSG: failed to open connection: Access denied for user
> 'amit'@'132.236.170.104' (using password: NO)

Can you connect using the mysql shell as the above user from machine  
132.236.170.104 without using a password? You supply the password to  
BioDB->new() using the -pass option.

> [...]
> Elswhere in my code I have a low-level query for my biosql db using
> DBI in which I connect to mysql reading a .my.cnf file:
>
> my $conn = DBI->connect("DBI:mysql:amit" .
> ";mysql_read_default_file=/home/amit/.my.cnf", $user, $passwd);
>
> Is there a way for to tell bioperl to read this .my.cnf file when it
> makes its database connection?

No, not until now. I added an option (-dsn) that lets you specify the  
dsn to be used verbatim for connecting. It should propagate to the  
anonymous cvs server over the next 1-2 hours. You can now also specify  
this option (--dsn) to load_{seqdatabase,ontology}.pl.

There is also an option -initrc that lets you specify a file that  
evaluates to a hash ref with all the parameters as keys. Check out the  
POD for Bio::DB::BioDB->new(). I also exposed this option (--initrc)  
now in load_{seqdatabase,ontology}.pl, apparently I had forgotten to do  
this before.

	-hilmar

 From the respective POD section I wrote on --initrc:

        --initrc paramfile
          Instead of, or in addition to, specifying every individual  
database
          connection parameter you may put them into a file that when  
read by
          perl evaluates to an array or hash reference. This option  
specifies
          the file to read; the special value DEFAULT (or no value) will  
use a
          file ./.bioperldb or $HOME/.bioperldb, whichever is found  
first in
          that order.

          Constructing a file that evaluates to a hash reference is very  
sim-
          ple. The first non-space character needs to be an open curly  
brace,
          and the last non-space character a closing curly brace. In  
between
          the curly braces, write option name, followed by => (equal to  
or
          greater than), followed by the value in single quotes.  
Separate each
          such option/value pair by comma. Here is an example:

          {
              -dbname => 'mybiosql', -host => 'foo.bar.edu', -user =>  
'cleo' }

          Line breaks and white space don't matter (except if in the  
value
          itself). Also note that options only have a single dash as  
prefix,
          and they need to be those accepted by Bio::DB::BioDB->new()
          (Bio::DB::BioDB) or Bio::DB::SimpleDBContext->new()  
(Bio::DB::Sim-
          pleDBContext). Those sometimes differ slightly from the option  
names
          used by this script, e.g., --dbuser corresponds to -user.

          Note also that using the above example, you can use it for  
--initrc
          and still connect as user caesar by also supplying --dbuser  
caesar on
          the command line. I.e., command line arguments override any  
parame-
          ters also found in the initrc file.

          Finally, note that if using this option with default file name  
and
          the default file is not found at any of the default locations,  
the
          option will be ignored; it is not considered an error.


>  For some reason to open a mysql
> connection on my machine i need to open up a ssh -L connection to the
> machine where the mysql server lives  with some funky parameters. (If
> this is more appropriate for biosql mailiing list, apologies but I
> didn't want to cross post :)
>
> Amit Indap
> Cornell University
>
> ------------- EXCEPTION  -------------
> MSG: failed to open connection: Access denied for user
> 'amit'@'132.236.170.104' (using password: NO)
> STACK Bio::DB::DBI::base::new_connection
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/DBI/base.pm:253
> STACK Bio::DB::DBI::base::get_connection
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/DBI/base.pm:213
> STACK Bio::DB::BioSQL::BasePersistenceAdaptor::dbh
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/BioSQL/ 
> BasePersistenceAdaptor.pm:1477
> STACK Bio::DB::BioSQL::BaseDriver::prepare_findbyuk_sth
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/BioSQL/BaseDriver.pm:515
> STACK Bio::DB::BioSQL::BasePersistenceAdaptor::_find_by_unique_key
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/BioSQL/ 
> BasePersistenceAdaptor.pm:927
> STACK Bio::DB::BioSQL::BasePersistenceAdaptor::find_by_unique_key
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/BioSQL/ 
> BasePersistenceAdaptor.pm:855
> STACK Bio::DB::BioSQL::PrimarySeqAdaptor::get_unique_key_query
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/BioSQL/PrimarySeqAdaptor.pm:395
> STACK Bio::DB::BioSQL::BasePersistenceAdaptor::find_by_unique_key
> /usr/lib/perl5/site_perl/5.8.5/Bio/DB/BioSQL/ 
> BasePersistenceAdaptor.pm:845
> STACK toplevel /home/amit/bin/HCG-blatparser.pl:181
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
>
-- 
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------




More information about the Bioperl-l mailing list