use DBI;
my $db_host = 'localhost';
my $db_user = 'postgres';
my $db_pass = '12345';
my $db_name = 'postgres';
my $db = "dbi:pg:dbname=${db_name};host=${db_host}";
$dbh = DBI->connect($db, $db_user, $db_pass,{ RaiseError => 1, AutoCommit => 0 }) || die "Error connecting to the database: $DBI::errstr\n";
my $query = "SELECT * FROM random_table";
$ref = $dbh->selectcol_arrayref($query);
print join("\n", @$ref);
当我执行这个文件时。我得到一个错误。它说:
DBD::pg 初始化失败:无法通过包“DBD::pg”找到对象方法“驱动程序”
我是否需要安装一些驱动程序才能连接到数据库..?