perl笔记之DBI操纵数据库
#!/usr/bin/perl use DBI;open AA,"c1";
my $dbname="sverlog";
my $location="localhost";
my $port="3306";
my $database="DBI:mysql:$dbname:$location:$port";
$dbh = DBI->connect($database,"mcshell","mcshell");
while(){
chomp;
if (/[^www]\s+(\S+)\s+(\S+);/){
my $sql="insert into webconfig (domain,webdir) values('$1','$2')";
my $sth=$dbh->prepare($sql);
$sth->execute() or die "无法执行SQL语句:$dbh->errstr";
}
}
$dbh->disconnect();
close AA;
页:
[1]