You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
521 B
Perl

use DBI;
$driver="DBI:mysql";
$database="sample_db";
$user="root";
$host="localhost";
$dbh=DBI->connect('dbi:mysql:sample_db','root','password',{
RaiseError => 1,
PrintError => 0,
}
) or die $DBI::errstr;
$sth=$dbh->prepare("SELECT name FROM Employee") or die "Can't prepare sql statement" . DBI->errstr;
$sth->execute();
while(my @val = $sth->fetchrow_array()){
print "name=$val[0]\n";
}
print $sth->rows," rows were retrieved.\n";
$sth->finish();
$dbh->disconnect();