Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.46 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use DBI;
  4. use warnings;
  5. use Data::Dumper;
  6.  
  7.  
  8. read_tables();
  9. #syslog_database_settings();
  10. #read_syslog_database();
  11. #break_apart_results();
  12. #customer_firewall_database_settings();
  13. #read_syslog_database();
  14.  
  15.  
  16. ##
  17. # This sub will query the database to get a list of the tables
  18. ##
  19.  
  20.  
  21.  
  22. sub read_tables {
  23.  
  24.    $host = "localhost";
  25.    $user = "root";
  26.    $pass = "password";
  27.    $database = "faz";
  28.    $db = "faz";
  29.    $query = "show tables";
  30.    $dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pass);
  31.  
  32.    $sqlQuery  = $dbh->prepare($query)
  33.         or die "Can't prepare $query:  $dbh->errstr\n";
  34.  
  35.    $rv = $sqlQuery->execute
  36.         or die "can't execute the query: $sqlQuery->errstr";
  37.  
  38.    while (@row= $sqlQuery->fetchrow_array()) {
  39.       my $tables = $row[0];
  40.       print "$row[0]\n";
  41.  
  42.       $myquery = $dbh->prepare("SELECT * FROM $tables")
  43.           or die "Can't prepare $query: $dbh->errstr\n";
  44.  
  45.       $myquery->execute
  46.           or die "can't execute the query: $sqlQuery->errstr";
  47.  
  48.    }
  49. }
  50.  
  51.  
  52.  
  53. The exact error is
  54.  
  55.  
  56. sydnms003:/home/ckilian/scripts# ./log.pl
  57.  
  58. FG100A3907507179-alog-20110323124340   <-------- THIS IS THE TABLE NAME
  59.  
  60. DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-alog-20110323124340' at line 1 at ./log.pl line 49.
  61. can't execute the query: DBI::st=HASH(0x92710a0)->errstr at ./log.pl line 49.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement