[Update] Re: Perl Interface to Informix?
Posted in 1996
Binh Thanh Nguyen wrote:
>
> >
> > Can someone tell me where I can find a perl interface to Informix?
> >
> > Many thanks,
> > George Cutrell
> > george.cutrell@mci.com
> >
>
> found at http://www.hermetica.com/technologia/DBI :
>
> get Perl5003 (or Perl5002 patch level 'm' and above)
> DBI-0.70.tar.gz (Database Interface) Alpha
> DBD-Informix-0.20pl1.tar (Informix Database Driver) Alpha
>
Ok,
Here is the update...with hope that Greg Wilson the ztools developer
and Joe the Informix expert would gladly forgive my previous blunders...
regards,
Binh Thanh Nguyen
CERFnet Inc.
-----------------------------------------------------------------------
I- Get the softwares (http://www.hermetica.com/technologia/DBI)
PERL5.0003.tar
DBI-0.71.tar
DBD-Informix-0.20pl1.tar
II- Install the all pieces...
-- Informix servers (if you would like to test the network features
of Perl5 -- Informix Interfaces then check /etc/services, and your
$INFORMIXDIR/etc/sqlhosts). I assume that you know of how
to set up trusted hosts (/etc/hosts.equiv) or trusted users ...etc
and you know what is $INFORMIXSERVER
EX: A hypothetical Local Database Server would have:
/etc/services contains
local_infx 5000/tcp # local server
infx1_tcp 6000/tcp # network server
$INFORMIXDIR/etc/sqlhosts
local_infx onipcshm mymachine local_infx
infx1_tcp ontlitcp servermachine infx1_tcp
Note: infx1_tcp database server is setup on "servermachine" which
contains stores7 database. Your local database server name is
"local_server".
-- Install Perl5.0003 (ON YOUR LOCAL DATABASE SERVER, of course)
DBI-0.71 (DBI-0.71 will NOT work with perl5.002)
DBD-Informix-0.20pl1
Note: if you only have DBI-0.70 use perl5.002 patch level 'm' or
above. However, why not update your perl ?
III- Time to test:
-- modify version of test.pl which is included in DBD-Informix-0.20pl
check list:
1- have you installed all softwares needed ?
a- Informix Servers (local, remote)
b- Perl 5.003
c- DBI-0.71
d- DBD-Informix-020pl (DB-Informix Driver)
2- Have you checked your your local and remote database configurations ?
a- /etc/services (both local and remote)
b- $INFORMIXDIR, $INFORMIXDIR/etc/sqlhosts (both local, and remote)
c- your local path to include
$INFORMIXDIR/bin:/usr/local/bin/perl ?
d- $INFORMIXSERVER (either local, or remote)
3- Have you checked the remote server's /etc/hosts.equiv ?
a- BECAREFUL with this security holes !!!
(Informix consultants please provide your comments !!!)
4- Have you forgotten or forgiven my ignorant statement about
Perl5-Informix and ztools ?
IV- TEST:
*) Use this script on your local server machine:
a- change $dbname to whatever the database you would like
to connect to
b- change $dbhost to remote Database Server machine if you would like
to test network connectivity.
c- change $dbuser to your login on remote Databse Server machine
(/etc/hosts.equiv)
===================================================================
infx_nettest.pl
====================================================================
#! /usr/local/bin/perl -w
BEGIN {
unshift @INC, "../../lib", "./lib";
}
use DBI;
$testtable = "items";
$dbname = 'stores7';
$dbhost = 'servermachine';
$dbuser = 'nbt';
$dbpass = 'xxx';
@mytable = {};
$i = 0;
# This part will install and connect the database driver through $drh
#
print "Testing: DBI->install_driver( 'Informix' ): ";
( $drh = DBI->install_driver( 'Informix' ) )
and print( "ok\\n" )
or die "not ok: $DBI::errstr\\n";
print "Testing: \\$drh->connect( $dbhost, $dbname, $dbuser, $dbpass ): ";
( $dbh = $drh->connect( $dbhost, $dbname, $dbuser, $dbpass ) )
and print("ok\\n")
or die "not ok: $DBI::errstr\\n";
# This part will try to prepare a statement that query against our
database
print "Testing: \\$cursor = \\$dbh->prepare( 'SELECT * FROM $testtable' ):
";
( $cursor = $dbh->prepare( "SELECT * FROM $testtable " ) )
and print( "ok\\n" )
or print( "not ok: $DBI::errstr\\n" );
print "Testing: \\$cursor->execute: ";
( $cursor->execute )
and print( "ok\\n" )
or print( "not ok: $DBI::errstr\\n" ); print (" My row $i :
@{$mytable[$i]}\\n");
$i++;
}
print "Re-testing: \\$cursor->finish: ";
( $cursor->finish )
and print( "ok\\n" )
or die "not ok: $DBI::errstr\\n";
print "*** Testing of DBD::Informix complete! You appear to be normal!
***\\n";
~
while ( @row = $cursor->fetchrow) {
$mytable[$i] = [@row];