]> git.donarmstrong.com Git - infobot.git/blobdiff - scripts/mysql2txt.pl
* Rename of insertDB.pl to factpack.pl
[infobot.git] / scripts / mysql2txt.pl
index c1a2c9364a34f5c01b4cfebc5c59873a4bf45469..b733e7625d7646d67bf3d5854522d93cbb8de775 100755 (executable)
@@ -11,37 +11,39 @@ require "src/Files.pl";
 $bot_src_dir = "./src/";
 
 my $dbname = shift;
-if (!defined $dbname) {
+if ( !defined $dbname ) {
     print "Usage: $0 <db name>\n";
     print "Example: $0 factoids\n";
     exit 0;
 }
 
 # open the db.
-&loadConfig("files/blootbot.config");
+&loadConfig("files/infobot.config");
 &loadDBModules();
 
-&openDB();
+&openDB( $param{'DBName'}, $param{'SQLUser'}, $param{'SQLPass'} );
 
 # retrieve a list of db's from the server.
 my %db;
-foreach ($dbh->func('_ListTables')) {
+foreach ( $dbh->func('_ListTables') ) {
     $db{$_} = 1;
 }
 
 # factoid db.
-if (!exists $db{$dbname}) {
+if ( !exists $db{$dbname} ) {
     print "error: $dbname does not exist as a table.\n";
     exit 1;
 }
 
 my $query = "SELECT factoid_key,factoid_value from $param{'DBName'}.$dbname";
-my $sth = $dbh->prepare($query);
+my $sth   = $dbh->prepare($query);
 $sth->execute;
-while (my @row = $sth->fetchrow_array) {
-  print "$row[0] => $row[1]\n";
+while ( my @row = $sth->fetchrow_array ) {
+    print "$row[0] => $row[1]\n";
 }
 $sth->finish;
 
 print "Done.\n";
 &closeDB();
+
+# vim:ts=4:sw=4:expandtab:tw=80