6

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
SemperFly
  • 1,563
  • 3
  • 17
  • 31
  • does DBI module provides interface for Teradata? Use `DBD::Teradata` module instead – Rahul Jun 29 '11 at 17:29
  • I've attempted this but that module is outdated for my version of Teradata. Gives me an error about deprecated logon credentials. – SemperFly Jun 29 '11 at 17:38
  • Well, I just googled a bit and found that almost everyone was not sucesfull with DBI OR DBD::ODBC for Teradata. One more I can suggest is that ... try with the Teradata ODBC driver which comes with Teradata client and see if it lets you pass through – Rahul Jun 29 '11 at 17:41
  • What version of DBD::ODBC are you using and which ODBC driver manager. – bohica Jun 30 '11 at 08:15

3 Answers3

4

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

David Harris
  • 2,332
  • 1
  • 13
  • 25
1

I'm pretty sure you've already found the answer but I'm going to post it anyway in case somebody else needs it:

odbcinst.ini:

[Teradata Database ODBC Driver 16.20]
Description=Teradata Database ODBC Driver 16.20
Driver=/opt/teradata/client/16.20/odbc_64/lib/tdataodbc_sb64.so
# Note: Currently, Data Direct Driver Manager does not support Connection Pooling feature.
CPTimeout=60

odbc.ini:

[ODBC Data Sources]
16.10=Teradata Database ODBC Driver 16.20
15.10=Teradata Database ODBC Driver 16.20
13.00=Teradata Database ODBC Driver 16.20
13.10=Teradata Database ODBC Driver 16.20
14.00=Teradata Database ODBC Driver 16.20

Note how the name of the data source can be anything, I chose the version in this case.

Perl code:

use DBD::ODBC;

my $conn = DBI->connect("DBI:ODBC:14.00",$username,$password);
#note how I'm connecting to the data source 14.00

my $create_user = $conn->prepare("CREATE USER $db_user from $username as perm = $perm, 
                                                password = XXXXXX,
                                                spool = $spool,
                                                NO fallback protection,
                                                default database = $db_user,
                                                NO after journal");
my $status = $create_user->execute();
$conn->disconnect();
the_ccalderon
  • 2,006
  • 2
  • 13
  • 24
1

$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.

bohica
  • 5,932
  • 3
  • 23
  • 28
  • Figured this out yesterday. I added additional information to my post. – SemperFly Jun 30 '11 at 16:58
  • So I guess (from those ini files) you are using the iODBC driver manager? Not my area of expertise really as I use unixODBC. However, I'd say from your files "tdsn" is the correct DSN to use so the DBI string needs to be "dbi:ODBC:tdsn". If that does not work set and export DBI_TRACE=15=x.log and add "DBI->trace(DBD::ODBC->parse_trace_flags('odbcconnection|odbcunicode'));" before the call to connect. Let us see what is in x.log after you run the code. – bohica Jul 01 '11 at 13:20