5 delete_nd_experiment_entries.pl - script to delete nd_experiment entries. used during phenotpe deletion to move the slow process of deleting nd_experiment entries to an asynchronous process
9 delete_nd_experiment_entries.pl -H [database handle] -D [database name] -U [database user] -P [database password] -i [filename of tempfile with nd_experiment_ids to delete]
17 -i filename of tempfile with nd_experiment_ids to delete
28 #use CXGN::DB::InsertDBH;
30 our ($opt_H, $opt_D, $opt_U, $opt_P, $opt_i);
31 getopts
('H:D:U:P:i:');
33 print STDERR
"Connecting to database...\n";
34 my $dsn = 'dbi:Pg:database='.$opt_D.";host=".$opt_H.";port=5432";
35 my $dbh = DBI
->connect($dsn, $opt_U, $opt_P);
37 my @nd_experiment_ids;
38 open (my $fh, "<", $opt_i ) || die ("\nERROR: the file $opt_i could not be found\n" );
39 while (my $line = <$fh>) {
41 push @nd_experiment_ids, $line;
46 my $nd_experiment_ids_string = join ",", @nd_experiment_ids;
47 my $q = "DELETE FROM nd_experiment WHERE nd_experiment_id IN ($nd_experiment_ids_string)";
48 my $h = $dbh->prepare($q);
50 print STDERR
"DELETED ".scalar(@nd_experiment_ids)." Nd Experiment Entries\n";
57 print STDERR
"Done, exiting delete_nd_experiment_entries.pl \n";