perl mysql DBI

To connect to a database from PERL you can use DBI, the Database independent interface. The following code snipped shows you how:
use DBI;
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost", "joe", "joe's password", {'RaiseError' => 1});
my $sth = $dbh->prepare("SELECT …. FROM articles WHERE article_id=?");
$sth->execute(1);
while(my @row = $sth->fetchrow_array()){
printf("%s\t%s\n%s\n",$row[0],$row[1],$row[4]);
}
$sth->finish();

Taggings:

Technology:

Subscribe to perl mysql DBI