当前位置:操作系统 > Unix/Linux >>

更新DBD-Pg模块

更新DBD-Pg模块
 
测试脚本如下:
#!/usr/bin/perl
 
use DBI;
use strict;
 
my $driver   = "Pg"; 
my $database = "testdb";
my $dsn = "DBI:$driver:dbname=$database;host=10.16.26.35;port=5432";
my $userid = "testrole";
my $password = "000000";
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) 
                      or die $DBI::errstr;
 
print "Opened database successfully\n";
 
 
my $stmt = qq(SELECT version() as version;);
my $sth = $dbh->prepare( $stmt );
my $rv = $sth->execute() or die $DBI::errstr;
if($rv < 0){
   print $DBI::errstr;
}
while(my @row = $sth->fetchrow_array()) {
      print "version = ". $row[0] . "\n";
}
print "Operation done successfully\n";
$dbh->disconnect();
 
perl g.pl
install_driver(Pg) failed: Can't locate DBD/Pg.pm in @INC (@INC contains: /usr/local/lib/perl5/5.10.0/x86_64-linux /usr/local/lib/perl5/5.10.0 /usr/local/lib/perl5/site_perl/5.10.0/x86_64-linux /usr/local/lib/perl5/site_perl/5.10.0 .) at (eval 3) line 3.
Perhaps the DBD::Pg perl module hasn't been fully installed,
or perhaps the capitalisation of 'Pg' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Oracle, Proxy, Sponge, Teradata.
 at g.pl line 11
 
检查了下已经存在相关的包了:
yum list installed | grep "perl-DB[DI]"
perl-DBD-MySQL.x86_64                      3.0007-2.el5                installed
perl-DBD-Pg.x86_64                         1.49-4.el5_8                installed
perl-DBI.x86_64                            1.52-2.el5                  installed
这是系统自带的安装包,去下载了个最新的更新之后问题解决。
yum -y install perl-* postgresql-jdbc-* qt-postgresql-* postgresql-server-* postgresql-devel-* postgresql-odbc-* postgresql-* postgresql-test-* postgresql-libs-* postgresql-plpython-* postgresql-docs-* postgresql-plperl-* postgresql-contrib-* postgresql-pltcl-*
tar -zxf DBD-Pg-2.19.3.tar.gz;cd DBD-Pg-2.19.3;perl Makefile.PL;make;make test;make install
 
perl g.pl
Opened database successfully
version = PostgreSQL 8.2.15 (Greenplum Database 4.2.3.2 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Jan 10 2013 18:27:37
Operation done successfully
测试通过。
-EOF-
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,