#!/usr/bin/perl $BASE_DIR="BASE_DIR"; $CGI_DIR="$BASE_DIR/cgi-bin"; print "This program will allow you to pull information with 1 select query from our databases\n\n"; print "What do you want? (seperate each item with a comma) "; $what=; print "Where do you want it from? (select a database)\n"; $whereDB=; print "What Table do you want it from? (select a table)\n"; $whereT=; print "Any special options? (like orderby, etc?)\n"; $options=; chop($file); chop($whereT); chop($whereDB); chop($what); chop($options); $sql="SELECT $what from $whereT $options"; print "What file name? "; $file=; `clear`; print "\nI am going to do this:\n $sql\n"; print "I am doing it to this: $whereDB\n\n"; print "If you do not want to do it, type N: "; $doit=; $driver="dbi:mysql:$whereDB"; $user="USER"; $password="password"; if ($doit eq "N"){die "You didnt want to do it!";} open(A,">$file"); use DBI; $dbh = DBI ->connect("$driver","$user","$password"); $sth = $dbh->prepare($sql); $sth->execute || die "Unable to connect to $whereDB Database!"; while(@row=$sth->fetchrow_array) { $a=$#row; $a++; $cnt=0; $strng=""; while($cnt<$a) { $strng=$strng."\"$row[$cnt]\","; $cnt++; } chop($strng); print A "$strng\n"; } $dbh->disconnect;