Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Teradata via Perl

Has anyone had any success with this? There aren't a great deal of references online and I've exhausted every relevant result on Google. Here's my script:

#!/usr/bin/perl

use DBI;
use DBD::ODBC;

$user = "user";
$pw = "pw";
$ip = "192.168.1.0"

#DBI->trace(DBD::ODBC->parse_trace_flags('odbconnection'));

#my $connect_attrs = { PrintError => 0, RaiseError => 1, AutoCommit => 1 };

my $dbh = DBI->connect("dbi:ODBC:$ip", $user, $pw);

The error message:

DBI connect('192.168.1.0','user',...) failed: (no error string) at ./teradata.pl line 13

The two lines that are commented out are leftover from my previous fruitless attempts to connect to the DB.

UPDATE: Here are the previous efforts I made with the DBD module.

#!/usr/bin/perl

use DBI;

$user = "xxxx";
$pw = "xxxx";

my $dbh = DBI->connect("dbi:Teradata:tdsn", $user, $pw);

Error:

DBI connect('tdsn','xxxx',...) failed: Unable to get host address. at ./teradata.pl line 12

Second Attempt:

#!/usr/bin/perl

use DBI;

$user = "xxxx";
$pw = "xxxx";

my $dbh = DBI->connect("dbi:Teradata:192.168.1.0", $user, $pw);

Error:

DBI connect('192.168.1.0','xxxx',...) failed: Deprecated logons are not allowed by administrator.  Upgrade client software to latest version. at ./teradata.pl line 12

Third...

#!/usr/bin/perl

use DBI;
use DBD::ODBC;

$user = "xxxx";
$pw = "xxxx";

my $dbh = DBI->connect("dbi:ODBC:tdsn", $user, $pw);

.odbc.ini

[ODBC]
InstallDir              = /usr/odbc
Trace           = 0
TraceDll                = /usr/odbc/lib/odbctrac.so
TraceFile               = /home/xxxx/odbctrace.log
TraceAutoStop           = 0

[ODBC Data Sources]
default         = tdata.so
testdsn         = tdata.so

[default]
Driver          = /usr/odbc/drivers/tdata.so
Description             = Default DSN is Teradata 5100
DBCName         = **ip_addr**
LastUser                = DLPStats
Username                = xxxx
Password                = xxxx
Database                = MSS_TEMP
DefaultDatabase         = MSS_TEMP

[tdsn]
Driver=/usr/odbc/drivers/tdata.so
Description=Teradata running Teradata V1R5.2
DBCName=**ip_addr**
LastUser=
Username=xxxx
Password=xxxx
Database=
DefaultDatabase=

Error:

DBI connect('tdsn','xxxx',...) failed: (no error string) at ./teradata.pl line 13

odbcinst.ini

[ODBC DRIVERS]
Teradata=Installed

[Teradata]
Driver=/usr/odbc/drivers/tdata.so
APILevel=CORE
ConnectFunctions=YYY
DriverODBCVer=3.51
SQLLevel=1
like image 968
SemperFly Avatar asked Jun 29 '11 17:06

SemperFly


2 Answers

You'll need to download and install the Teradata DBD module.

like image 64
David Harris Avatar answered Oct 05 '22 15:10

David Harris


$ip cannot be an IP address. It needs to be the name of an ODBC data source which is known to your ODBC driver manager. We'd need to know your driver manager to help further. Assuming it is unixODBC, you'll have an odbcinst.ini file the teradata driver needs to be named in with a line pointing to the driver shared object. Then in the odbc.ini file you create a data source.

like image 20
bohica Avatar answered Oct 05 '22 13:10

bohica