[ensembl-dev] problem connecting to ensembl directly with DBConnector

Pablo Marin-Garcia pg4 at sanger.ac.uk
Thu Dec 30 23:10:07 GMT 2010


Hello Andrea,

As Ian has said, now the latest ensembl mysql instances are in the port 5306. So 
he has already answered your question.

But I only would like to point that unless 
there is an inevitable cause for using a direct and explicit connection with 
DBConnection, I would suggest connecting using the Registry:

--- <code>---
use Bio::EnsEMBL::Registry;

my $reg = 'Bio::EnsEMBL::Registry';

$reg->load_registry_from_db(-host => 'ensembldb.ensembl.org', 
-user=>'anonymous') ;

---</code>---

This will connect to the database that match your API version. So your scripts 
are more flexible and prevent database-API mismatches when you update ensembl 
code. In order to use different database versions  you only need to change your 
PERL5LIB environmental variable (or 'use lib') pointing to the ensembl API 
checkout of the desired version.


    -Pablo



On Thu, 30 Dec 2010, Ian Sealy wrote:

> Dear Andrea,
>
>> What should the database name be for this code to work on the ensembl human 
>> core/variation and cow core/variation databases?
>
>> This code works fine when it run it against local installations but says 
>> dbname does not exist when i run against ensembl server. I looked up most 
>> recent database name from ftp site.
>>
>>  $dbc = Bio::EnsEMBL::DBSQL::DBConnection->new(    -user   => 'anonymous', 
>> -dbname => 'homo_sapiens_variation_60_37e',    -host   => 
>> 'ensembldb.ensembl.org',    -driver => 'mysql',  );
>>  # SQL statements should be created/executed through this modules
>>  # prepare() and do() methods.
>> 
>> $sql =  "select allele_id from allele limit 100";
>> $sth = $dbc->prepare($sql);
>> 
>> 
>> 
>> Could not connect to database homo_sapiens_variation_60_37e as user 
>> anonymous using 
>> [DBI:mysql:database=homo_sapiens_variation_60_37e;host=ensembldb.ensembl.org;port=3306] 
>> as a locator:
>> Unknown database 'homo_sapiens_variation_60_37e' at 
>> C:\Perl\site\lib\ensembl-api\ensembl\modules/Bio/EnsEMBL/DBSQL/DBConnection.pm 
>> line 290.
>> 
>> -------------------- EXCEPTION --------------------
>> MSG: Could not connect to database homo_sapiens_variation_60_37e as user 
>> anonymous using 
>> [DBI:mysql:database=homo_sapiens_variation_60_37e;host=ensembldb.ensembl.org;port=3306] 
>> as a locator:
>> Unknown database 'homo_sapiens_variation_60_37e'
>> STACK Bio::EnsEMBL::DBSQL::DBConnection::connect 
>> C:\Perl\site\lib\ensembl-api\ensembl\modules/Bio/EnsEMBL/DBSQL/DBConnection.pm:299
>> STACK Bio::EnsEMBL::DBSQL::DBConnection::db_handle 
>> C:\Perl\site\lib\ensembl-api\ensembl\modules/Bio/EnsEMBL/DBSQL/DBConnection.pm:618
>> STACK Bio::EnsEMBL::DBSQL::DBConnection::prepare 
>> C:\Perl\site\lib\ensembl-api\ensembl\modules/Bio/EnsEMBL/DBSQL/DBConnection.pm:647
>> STACK toplevel C:/Documents and 
>> Settings/Administrator/Desktop/PHD/java/Code/ensembl 
>> database/variation.pl:23
>> 
>> 
>> Are there any other ways to issue SQL queries directly?
>
> From version 48 onwards, you need to change the port from the default 3306 to 
> 5306. Like so:
>
> mysql -h ensembldb.ensembl.org -u anonymous -e "SHOW DATABASES LIKE 
> 'homo_sapiens_variation_60_37e'"
> mysql -h ensembldb.ensembl.org -u anonymous -P 5306 -e "SHOW DATABASES LIKE 
> 'homo_sapiens_variation_60_37e'"
> +------------------------------------------+
> | Database (homo_sapiens_variation_60_37e) |
> +------------------------------------------+
> | homo_sapiens_variation_60_37e            |
> +------------------------------------------+
>
> For more info, see:
>
> http://www.ensembl.org/info/data/mysql.html
>
> Cheers,
> Ian
>
> _______________________________________________
> Dev mailing list
> Dev at ensembl.org
> http://lists.ensembl.org/mailman/listinfo/dev
>


-----

   Pablo Marin-Garcia





More information about the Dev mailing list