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

Ian Sealy is1 at sanger.ac.uk
Thu Dec 30 16:59:02 GMT 2010


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




More information about the Dev mailing list