Included libraries | Package variables | General documentation | Methods |
WebCvs | Raw content |
connect | No description | Code |
db_Main | No description | Code |
connect | description | prev | next | Top |
my $self = shift; my $species = shift || __PACKAGE__->species_defs->ENSEMBL_PRIMARY_SPECIES; my $db = shift || 'DATABASE_CORE'; my $db_info = __PACKAGE__->species_defs->get_config($species, 'databases'); my $dsn = join(':', 'dbi', 'mysql', $db_info->{$db}{'NAME'}, $db_info->{$db}{'HOST'}, $db_info->{$db}{'PORT'}, ); if ($dbh{$dsn}) { $self->{__current_dbh} = $dbh{$dsn}; } else { $self->{__current_dbh} = $dbh{$dsn} = DBI->connect_cached( $dsn, __PACKAGE__->species_defs->DATABASE_WRITE_USER, __PACKAGE__->species_defs->DATABASE_WRITE_PASS, { RaiseError => 1, PrintError => 1, AutoCommit => 1, } ); if (not $self->{__current_dbh}) { warn "Could not connect to '$dsn' $DBI::errstr"; return 0; } } $current_dbh = $self->{__current_dbh}; return 1;}
db_Main | description | prev | next | Top |
my $self = shift; if (ref $self) { return $self->{__current_dbh}; } else { return $current_dbh; } } 1;}