面试题答案
一键面试use DBI;
# 连接到SQLite数据库
my $dbh = DBI->connect('dbi:SQLite:dbname=your_database.db', '', '', { RaiseError => 1 });
# 执行查询
my $sth = $dbh->prepare('SELECT name, salary FROM employees WHERE salary > 5000');
$sth->execute();
# 打印结果
while (my @row = $sth->fetchrow_array) {
print "Name: $row[0], Salary: $row[1]\n";
}
# 断开数据库连接
$sth->finish();
$dbh->disconnect();