DBI, connect(), prepare(), execute(), fetchrow_array()


#!/usr/bin/perl 
use strict; 
use DBI; 

my $dbh = DBI->connect("dbi:mysql:dbname", 'user','passwd', '') 
or die "can't connect!\n"; 
my $sql = qq/show variables/; 
my $sth = $dbh->prepare($sql); 
$sth->execute(); 

while(my @array=$sth->fetchrow_array()) 
{ 
   printf("%-35s", $_) foreach(@array); 
   print "\n"; 
} 
$dbh -> disconnect(); 
exit 0;


你可能感兴趣的:(DBI, connect(), prepare(), execute(), fetchrow_array())