Guest User

Untitled

a guest
May 1st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use DBI;
  3.  
  4. $database = "onomavasis";
  5. $hostname = "tohostname";
  6. $port = "3306";
  7. $username = "tousername";
  8. $password = 'okwdikos';
  9.  
  10. $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
  11.  
  12. $dbh = DBI->connect($dsn, $username, $password) or die("Could not connect!");
  13.  
  14. $sql = "SELECT * FROM mytable";
  15.  
  16. $sth = $dbh->prepare($sql);
  17. $sth->execute;
  18.  
  19.  
  20. while(($column1, $column2) = $sth->fetchrow_array)
  21. {
  22. print "C1 = $column1, C2 = $column2n";
  23. }
  24.  
  25.  
  26.  
  27. $dbh->disconnect;
Add Comment
Please, Sign In to add comment