Friday, July 29, 2011

Install Perl DBD:MYSQL || PERL & MYSL Connectivity

Install Perl DBD:MYSQL:

UBUNTU:
Type Terminal below commands:
perl -MCPAN -e shell
install DBD::mysql

PERL & MYSL Connectivity:

#!/usr/bin/perl -w
use DBI;
$dbh = DBI->connect('dbi:mysql:siva','root','siva123')
or die "Connection Error: $DBI::errstr\n";
$sql = "select * from concern_emp";
$sth = $dbh->prepare($sql);
$sth->execute
or die "SQL Error: $DBI::errstr\n";
while (@row = $sth->fetchrow_array) {
print "@row\n";
}

OUTPUT:
45 Amala B. 1014 4 0207 2011-01-27 11:30:57
46 Vidhya K. 1009 4 0207 2011-01-27 11:31:11
47 Nithya D. 4006 4 0207 2011-01-27 11:31:18
48 Vanitha S. 1020 4 0207 2011-01-27 11:31:52

No comments:

Post a Comment