Commit 15e96af9 authored by Leo Gordon's avatar Leo Gordon
Browse files

Support extra parameters added to the client's command line

parent 478f6740
......@@ -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 "\nRunning 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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment