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
dea54850
Commit
dea54850
authored
22 years ago
by
Arne Stabenau
Browse files
Options
Downloads
Patches
Plain Diff
ups wrong directory ...
parent
1274ce4a
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
misc-scripts/multidb_sql
+0
-73
0 additions, 73 deletions
misc-scripts/multidb_sql
with
0 additions
and
73 deletions
misc-scripts/multidb_sql
deleted
100644 → 0
+
0
−
73
View file @
1274ce4a
# apply given sql statement to all databases on a given host
# you can specify a name pattern for the database
# it displays results for select statements
# Author: Arne Stabenau
# Date : 21.02.2003
use strict;
use DBI;
use Getopt::Long;
my ( $host, $user, $pass, $port, $expression, $dbpattern );
GetOptions( "host=s", \$host,
"user=s", \$user,
"pass=s", \$pass,
"port=i", \$port,
"expr=s", \$expression,
"dbpattern=s", \$dbpattern
);
if( !$host ) {
usage();
}
my $dsn = "DBI:mysql:host=$host";
if( $port ) {
$dsn .= ";port=$port";
}
my $db = DBI->connect( $dsn, $user, $pass );
my @dbnames = map {$_->[0] } @{ $db->selectall_arrayref( "show databases" ) };
for my $dbname ( @dbnames ) {
if( $dbpattern ) {
if( $dbname !~ /$dbpattern/ ) {
next;
}
}
$db->do( "use $dbname" );
print STDERR "$dbname\n";
if( $expression =~ /^\s*select/i ||
$expression =~ /^\s*show/i ||
$expression =~ /^\s*describe/i ) {
my $res = $db->selectall_arrayref( $expression );
my @results = map { join( " ", @$_ ) } @$res ;
for my $result ( @results ) {
print STDERR " Result: ",$result,"\n";
}
} else {
$db->do( $expression );
print STDERR " done.\n";
}
}
sub usage {
print STDERR <<EOF
Usage: multidb_sql options
Where options are: -host hostname
-user username
-pass password
-port port_of_server optional
-dbpattern regular expression that the database name has to match
-expr sql statement you want to execute. Has to be a select.
EOF
;
}
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