Perl Mysql Database connection
How do i connect mysql database using perl. Will like to see sample codes so i can quickly try it out. Thanks
|
Quote:
$database='nameofdatabase'; $host='localhost'; $port='3306'; $user='root'; $password=""; $dsn = "DBI:mysql:database=$database;host=$host;port=$port" or die "Connection Error: $DBI::errstr\n"; $dbh = DBI->connect($dsn, $user, $password); $sql = "show tables"; $sth = $dbh->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; hope this helps........ |
All times are GMT -5. The time now is 08:35 AM. |