执行结果:#!/bin/perl
use DBI;
# Connect to target DB
my $dbh = DBI->connect("DBI:mysql:database=eygle;host=localhost","username","password", {'RaiseError' => 1});# Insert one row
my $rows = $dbh->do("INSERT INTO test (id, name) VALUES (1, 'eygle')");# query
my $sqr = $dbh->prepare("SELECT name FROM test");
$sqr->execute();while(my $ref = $sqr->fetchrow_hashref()) {
print "$ref->{'name'}\n";
}$dbh->disconnect();
[root@eygle ~]# perl test.cgi eygle以后很多统计数据可以直接通过Perl写入Mysql数据库,操作起来方便多了。 看来这次迁移是值得的:) -The End-