squash perl 5.12 warning
[bioperl-db.git] / scripts / biosql / drop_mysql_biosql_test_dbs
blobdd8f45824232cbaa25b47b2d0889dd6e86a8e512
1 #!/usr/bin/perl
2 use strict;
3 use DBI;
4 my $dns="DBI:mysql:host=localhost";
5 my $dbh=DBI->connect($dns, 'root', '') or die "Connect error: $DBI::error";
7 my $table_pattern='_test_db_%';
8 my $sql="SHOW DATABASES LIKE '$table_pattern'";
9 my $sth=$dbh->prepare($sql);
10 $sth->execute;
11 my $arrayref=$sth->fetchall_arrayref;
13 print join("\n", map{$_->[0]} @$arrayref), "\n";
15 for my $db_name (map{$_->[0]} @$arrayref){
16 $sql="DROP DATABASE $db_name";
17 $dbh->do($sql);
20 __END__
22 =head1 NAME
24 drop_mysql_biosql_test_dbs
26 =head1 SYNOPSIS
28 In shell command line,
30 drop_mysql_biosql_test_dbs
33 =head1 DESCRIPTION
35 THIS script is for bioperl-db developers to drop all test databases,
36 which may be generated during runing 'make test'.
38 NOTE: This script is only for mysql database, since within my knowledge on
39 DBI, I do not know how to connect to Oracle host without specific database.
40 As well, I do not have Oracle installed. You are welcome to adapt it into
41 Oracle and other RDBMS! :-)
43 =head1 AUTHOR
45 Juguang XIAO, juguang at tll.org.sg
47 =cut