6 # Finding out own path in order to reference own components (including own modules):
10 $ENV{
'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Cwd::realpath($0) ) );
11 unshift @INC, $ENV{
'EHIVE_ROOT_DIR'}.
'/modules';
14 use Getopt::Long qw(:config no_auto_abbrev);
22 my ($reg_conf, $reg_type, $reg_alias, $executable, $url, @prepend, @append, $sqlcmd, $verbose, $help, $report_versions);
25 # connect to the database:
26 'reg_conf=s' => \$reg_conf,
27 'reg_type=s' => \$reg_type,
28 'reg_alias=s' => \$reg_alias,
30 'exec|executable=s' => \$executable,
32 'prepend=s@' => \@prepend,
33 'append|extra=s@' => \@append,
34 'sqlcmd|sql=s' => \$sqlcmd,
36 'verbose!' => \$verbose,
38 'v|version|versions!' => \$report_versions,
39 ) or die "Error in command line arguments\n";
45 pod2usage({-exitvalue => 0, -verbose => 2});
47 } elsif($report_versions) {
52 } elsif( not ($url xor $reg_alias) ) {
53 die
"\nERROR: Connection parameters (url or reg_conf+reg_alias) need to be specified\n";
58 -reg_conf => $reg_conf,
59 -reg_type => $reg_type,
60 -reg_alias => $reg_alias,
61 -no_sql_schema_version_check => 1,
68 warn qq{In db_cmd.pl,
final arguments don
't have to be declared with --append any more. All the remaining arguments are considered to be appended.\n};
71 my @cmd = @{ $dbc->to_cmd( $executable, \@prepend, [@append, @ARGV], $sqlcmd ) };
72 $dbc->disconnect_if_idle;
75 my $flat_cmd = join(' ', map { ($_=~/^-?\w+$/) ? $_ : "\"$_\"" } @cmd);
77 warn "\nThe actual command I am running is:\n\t$flat_cmd\n\n";
96 db_cmd.pl {-url <url> | [-reg_conf <reg_conf>] -reg_alias <reg_alias> [-reg_type <reg_type>] } [ -exec <alt_executable> ] [ -prepend <prepend_params> ] [ -sql <sql_command> ] [ -verbose ] [other arguments to append to the command line]
100 db_cmd.pl is a generic script that connects you interactively to your database using either URL or Registry and optionally runs an SQL command.
108 URL defining where eHive database is located
110 =item --reg_conf <path>
112 path to a Registry configuration file
114 =item --reg_alias <str>
116 species/alias name for the eHive DBAdaptor
118 =item --executable <name|path>
120 The executable to run instead of the driver's
default (which is the command-line client)
122 =item --prepend <string>
124 Argument that has to be prepended to the connection details. This option can be repeated
128 SQL command to execute
132 Print the command before running it.
136 Print
this help message
140 All the remaining arguments are passed on to the command to be
run.
141 If some of them start with a dash, first use a
double-dash to indicate the end of db_cmd.pl
's options and the start of the arguments that have to be passed as is (see the example below with --html)
143 =head1 USAGE EXAMPLES
145 db_cmd.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost:3306/" -sql 'CREATE DATABASE lg4_long_mult
'
146 db_cmd.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost:3306/lg4_long_mult"
147 db_cmd.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost:3306/lg4_long_mult" -sql 'SELECT * FROM analysis_base
' -- --html
148 db_cmd.pl -url "mysql://ensadmin:${ENSADMIN_PSW}@localhost/lg4_long_mult" -exec mysqldump -prepend -t analysis_base job
150 db_cmd.pl -reg_conf ${ENSEMBL_CVS_ROOT_DIR}/ensembl-compara/scripts/pipeline/production_reg_conf.pl -reg_alias compara_master
151 db_cmd.pl -reg_conf ${ENSEMBL_CVS_ROOT_DIR}/ensembl-compara/scripts/pipeline/production_reg_conf.pl -reg_alias mus_musculus -reg_type core
152 db_cmd.pl -reg_conf ${ENSEMBL_CVS_ROOT_DIR}/ensembl-compara/scripts/pipeline/production_reg_conf.pl -reg_alias squirrel -reg_type core -sql 'SELECT * FROM coord_system
'
156 See the NOTICE file distributed with this work for additional information
157 regarding copyright ownership.
159 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
160 You may obtain a copy of the License at
162 http://www.apache.org/licenses/LICENSE-2.0
164 Unless required by applicable law or agreed to in writing, software distributed under the License
165 is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166 See the License for the specific language governing permissions and limitations under the License.
170 Please subscribe to the eHive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss eHive-related questions or to be notified of our updates