Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
8c36d61c
Commit
8c36d61c
authored
18 years ago
by
Patrick Meidl
Browse files
Options
Downloads
Patches
Plain Diff
added get_dbconnection()
parent
4403a9a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+56
-2
56 additions, 2 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
with
56 additions
and
2 deletions
modules/Bio/EnsEMBL/Utils/ConversionSupport.pm
+
56
−
2
View file @
8c36d61c
...
...
@@ -52,6 +52,7 @@ use Bio::EnsEMBL::Utils::Exception qw(throw warning);
use
FindBin
qw($Bin $Script)
;
use
POSIX
qw(strftime)
;
use
Cwd
qw(abs_path)
;
use
DBI
;
=head2 new
...
...
@@ -139,7 +140,7 @@ sub parse_common_options {
$self
->
param
(
$name
,
$val
);
}
$self
->
param
('
conffile
',
$conffile
);
}
els
e
{
}
els
if
(
$conffile
)
{
warning
("
Unable to open configuration file
$conffile
for reading: $!
");
}
...
...
@@ -651,6 +652,59 @@ sub get_database {
return
$self
->
{'
_dba
'}
->
{
$database
};
}
=head2 get_dbconnection
Arg[1] : (optional) String $prefix - the prefix used for retrieving the
connection settings from the configuration
Example : my $dbh = $self->get_dbconnection;
Description : Connects to the database server specified. You don't have to
specify a database name (this is useful for running commands
like $dbh->do('show databases')).
Return type : DBI database handle
Exceptions : thrown if connection fails
Caller : general
Status : At Risk
=cut
sub
get_dbconnection
{
my
$self
=
shift
;
my
$prefix
=
shift
;
$self
->
check_required_params
(
"
${prefix}
host
",
"
${prefix}
port
",
"
${prefix}
user
",
);
my
$dsn
=
"
DBI:
"
.
(
$self
->
param
('
driver
')
||
'
mysql
')
.
"
:host=
"
.
$self
->
param
("
${prefix}
host
")
.
"
;port=
"
.
$self
->
param
("
${prefix}
port
");
if
(
$self
->
param
("
${prefix}
dbname
"))
{
$dsn
.=
"
;dbname=
"
.
$self
->
param
("
${prefix}
dbname
");
}
my
$dbh
;
eval
{
$dbh
=
DBI
->
connect
(
$dsn
,
$self
->
param
("
${prefix}
user
"),
$self
->
param
("
${prefix}
pass
"),
{'
RaiseError
'
=>
1
,
'
PrintError
'
=>
0
});
};
if
(
!
$dbh
||
$@
||
!
$dbh
->
ping
)
{
$self
->
log_error
("
Could not connect to db server as user
"
.
$self
->
param
("
${prefix}
user
")
.
"
using [
$dsn
] as a locator:
\n
"
.
$
DBI::
errstr
);
}
$self
->
{'
_dbh
'}
=
$dbh
;
return
$self
->
{'
_dbh
'};
}
=head2 get_glovar_database
Example : my $dba = $support->get_glovar_database;
...
...
@@ -1294,7 +1348,7 @@ sub init_log {
sub
finish_log
{
my
$self
=
shift
;
$self
->
log
("
All done.
"
.
$self
->
warnings
.
"
warnings.
");
$self
->
log
("
\n
All done.
"
.
$self
->
warnings
.
"
warnings.
");
if
(
$self
->
{'
_start_time
'})
{
$self
->
log
("
Runtime
");
my
$diff
=
time
-
$self
->
{'
_start_time
'};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment