4 drop_test_databases.pl - a script to remove test databases from the postgres instance
8 When using t/test_fixture.pl with the --nocleanup option, a lot of test databases (named test_db_* ) can accumulate in the postgres instance.
10 drop_dest_databases.pl will remove all databases whose names start with test_db_.
12 It will ask for a postgres username (default postgres) and a password and then proceed to deletion immediately.
16 Lukas Mueller <lam87@cornell.edu>
26 use CXGN
::DB
::InsertDBH
;
32 print STDERR
"Deleting test databases (test_db_%) from $opt_h...\n";
33 my $dbh = CXGN
::DB
::InsertDBH
->new( { dbhost
=> $opt_h, dbname
=> 'postgres', dbargs
=> { AutoCommit
=> 1 } } );
36 my $q = "SELECT datname FROM pg_database WHERE datname ilike 'test_db_%'";
38 my $h = $dbh->prepare($q);
43 while (my ($dbname) = $h->fetchrow_array()) {
47 foreach my $dbname (@dbs) {
48 print STDERR
"Dropping database $dbname...\n";
49 my $d = "DROP DATABASE $dbname";
50 my $h = $dbh->prepare($d);
54 print STDERR
"Done.\n";