Windows 10 64bit上的Strawberry Perl Firebird驱动程序和模块

时间:2019-07-17 09:41:08

标签: perl firebird dbi strawberry-perl

我似乎无法编译并安装Firebird驱动程序以在Windows 10 64bit上运行的Strawberry Perl中使用。

我遵循的步骤包括:

  1. 下载并安装Strawberry Perl最新的32位驱动程序。

  2. 从控制台运行cpan

  3. 在cpan内部使用此install DBD::Firebird

  4. 该模块已下载并安装,但是连接到另一台Windows计算机上的Firebird数据库失败。

要连接的Perl代码如下:

sub IB_CONNECT {
    #database connection parameters
    use DBI;
    $dbname = 'db=192.168.0.12:c:/IXP220/Database/DB220.fdb';
    $user = 'SYSDBA';
    $password = 'masterkey';
    $firebirdDSN='dbi:Firebird:DRIVER={Firebird};' . $dbname;
    $dbhIB = DBI->connect($firebirdDSN,$user,$password);
}

请有人能启发我如何连接到该数据库吗?

1 个答案:

答案 0 :(得分:3)

我通常不使用Perl,但是由于一些试验和错误,我安装了DBD :: Firebird并做了一个保存为connect.pl的小测试:

use DBI;

$dbh = DBI->connect("dbi:Firebird:db=employee;host=localhost", "sysdba", "masterkey");

$sth = $dbh->prepare("SELECT country, currency FROM country");

$sth->execute();

while ( @row = $sth->fetchrow_array ) {
  print "@row\n";
}

如果我没有安装32位fbclient.dll,则perl connect.pl会导致错误:

install_driver(Firebird) failed: Can't load 'D:/DevSoft/Strawberry/perl/site/lib/auto/DBD/Firebird/Firebird.xs.dll' for module DBD::Firebird: load_file:The specified module could not be found at D:/DevSoft/Strawberry/perl/lib/DynaLoader.pm line 193.
  at (eval 8) line 3.
Compilation failed in require at (eval 8) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at connect.pl line 3.

在安装32位fbclient.dll之后,此方法有效(结果是Firebird附带的Employee示例数据库的COUNTRY表):

USA Dollar
England Pound
Canada CdnDlr
Switzerland SFranc
Japan Yen
Italy Euro
France Euro
Germany Euro
Australia ADollar
Hong Kong HKDollar
Netherlands Euro
Belgium Euro
Austria Euro
Fiji FDollar
Russia Ruble
Romania RLeu

要安装32位fbclient.dll,可以执行以下操作之一:

  • 下载并运行32 bit installer for Firebird,并使用“最小客户端安装-无服务器,无工具”安装选项;
  • 如果您的计算机上已经安装了64位Firebird,请打开管理员命令提示符,然后转到Firebird安装的SysWoW64文件夹(此文件夹包含32位客户端库),然后执行instclient i f;
  • 下载32 bit Firebird zip kit并解压缩,打开管理员命令提示符,然后转到解压缩的zip工具包的位置,然后执行instclient i f