Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
15e96af9
Commit
15e96af9
authored
Aug 14, 2013
by
Leo Gordon
Browse files
Support extra parameters added to the client's command line
parent
478f6740
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
scripts/db_conn.pl
scripts/db_conn.pl
+11
-8
No files found.
scripts/db_conn.pl
View file @
15e96af9
...
...
@@ -18,7 +18,7 @@ use Bio::EnsEMBL::Hive::Utils ('script_usage');
sub
main
{
my
(
$reg_conf
,
$reg_type
,
$reg_alias
,
$url
,
$sqlcmd
,
$verbose
,
$help
);
my
(
$reg_conf
,
$reg_type
,
$reg_alias
,
$url
,
$sqlcmd
,
$extra
,
$verbose
,
$help
);
GetOptions
(
# connect to the database:
...
...
@@ -29,6 +29,7 @@ sub main {
'
url=s
'
=>
\
$url
,
'
sqlcmd=s
'
=>
\
$sqlcmd
,
'
extra=s
'
=>
\
$extra
,
'
verbose!
'
=>
\
$verbose
,
'
help!
'
=>
\
$help
,
...
...
@@ -61,7 +62,7 @@ sub main {
script_usage
(
1
);
}
my
$cmd
=
dbc_hash_to_cmd
(
$dbc_hash
,
$sqlcmd
);
my
$cmd
=
dbc_hash_to_cmd
(
$dbc_hash
,
$sqlcmd
,
$extra
);
print
"
\n
Running command:
\t
$cmd
\n\n
"
if
(
$verbose
);
...
...
@@ -69,7 +70,9 @@ sub main {
}
sub
dbc_hash_to_cmd
{
my
(
$dbc_hash
,
$sqlcmd
)
=
@_
;
my
(
$dbc_hash
,
$sqlcmd
,
$extra
)
=
@_
;
$extra
||=
'';
my
$cmd
;
...
...
@@ -79,7 +82,7 @@ sub dbc_hash_to_cmd {
$cmd
=
"
mysql --host=
$dbc_hash
->{host}
"
.
(
defined
(
$dbc_hash
->
{
port
})
?
"
--port=
$dbc_hash
->{port}
"
:
'')
.
"
--user='
$dbc_hash
->{user}' --pass='
$dbc_hash
->{pass}'
$dbc_hash
->{dbname}
"
.
"
--user='
$dbc_hash
->{user}' --pass='
$dbc_hash
->{pass}'
$extra
$dbc_hash
->{dbname}
"
.
(
defined
(
$sqlcmd
)
?
"
-e '
$sqlcmd
'
"
:
'');
}
elsif
(
$driver
eq
'
pgsql
')
{
...
...
@@ -87,11 +90,11 @@ sub dbc_hash_to_cmd {
.
(
defined
(
$dbc_hash
->
{
port
})
?
"
--port=
$dbc_hash
->{port}
"
:
'')
.
"
--username='
$dbc_hash
->{user}'
"
.
(
defined
(
$sqlcmd
)
?
"
--command='
$sqlcmd
'
"
:
'')
.
"
$dbc_hash
->{dbname}
";
.
"
$extra
$dbc_hash
->{dbname}
";
}
elsif
(
$driver
eq
'
sqlite
')
{
if
(
$dbc_hash
->
{
dbname
})
{
$cmd
=
"
sqlite3
$dbc_hash
->{dbname}
"
$cmd
=
"
sqlite3
$extra
$dbc_hash
->{dbname}
"
.
(
defined
(
$sqlcmd
)
?
"
'
$sqlcmd
'
"
:
'');
}
elsif
(
$sqlcmd
=~
/DROP\s+DATABASE\s+(?:IF\s+EXISTS\s+)?(\w+)/i
)
{
$cmd
=
"
rm -f $1
";
...
...
@@ -116,7 +119,7 @@ __DATA__
=head1 SYNOPSIS
db_conn.pl {-url <url> | -reg_conf <reg_conf> -reg_alias <reg_alias> [-reg_type <reg_type>] } [ -sql <sql_command> ] [ -verbose ]
db_conn.pl {-url <url> | -reg_conf <reg_conf> -reg_alias <reg_alias> [-reg_type <reg_type>] } [ -sql <sql_command> ] [
-extra <extra_params> ] [
-verbose ]
=head1 DESCRIPTION
...
...
@@ -126,7 +129,7 @@ __DATA__
db_conn.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost:3306/" -sql 'CREATE DATABASE lg4_long_mult'
db_conn.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost:3306/lg4_long_mult"
db_conn.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost:3306/lg4_long_mult" -sql 'SELECT * FROM analysis_base'
db_conn.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost:3306/lg4_long_mult" -sql 'SELECT * FROM analysis_base'
-extra='--html'
db_conn.pl -reg_conf ${ENSEMBL_CVS_ROOT_DIR}/ensembl-compara/scripts/pipeline/production_reg_conf.pl -reg_alias compara_master -reg_type compara
db_conn.pl -reg_conf ${ENSEMBL_CVS_ROOT_DIR}/ensembl-compara/scripts/pipeline/production_reg_conf.pl -reg_alias compara_prev -reg_type compara
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment