title: Connecting to Teradata via Perl
body: <p>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:</p>
  
  <pre><code>#!/usr/bin/perl
  
  use DBI;
  use DBD::ODBC;
  
  $user = "user";
  $pw = "pw";
  $ip = "192.168.1.0"
  
  #DBI-&gt;trace(DBD::ODBC-&gt;parse_trace_flags('odbconnection'));
  
  #my $connect_attrs = { PrintError =&gt; 0, RaiseError =&gt; 1, AutoCommit =&gt; 1 };
  
  my $dbh = DBI-&gt;connect("dbi:ODBC:$ip", $user, $pw);
  </code></pre>
  
  <p>The error message:</p>
  
  <pre><code>DBI connect('192.168.1.0','user',...) failed: (no error string) at ./teradata.pl line 13
  </code></pre>
  
  <p>The two lines that are commented out are leftover from my previous fruitless attempts to connect to the DB.</p>
  
  <p><strong>UPDATE</strong>: Here are the previous efforts I made with the DBD module.</p>
  
  <pre><code>#!/usr/bin/perl
  
  use DBI;
  
  $user = "xxxx";
  $pw = "xxxx";
  
  my $dbh = DBI-&gt;connect("dbi:Teradata:tdsn", $user, $pw);
  </code></pre>
  
  <p><strong>Error:</strong> </p>
  
  <pre><code>DBI connect('tdsn','xxxx',...) failed: Unable to get host address. at ./teradata.pl line 12
  </code></pre>
  
  <hr>
  
  <p><strong>Second Attempt:</strong></p>
  
  <pre><code>#!/usr/bin/perl
  
  use DBI;
  
  $user = "xxxx";
  $pw = "xxxx";
  
  my $dbh = DBI-&gt;connect("dbi:Teradata:192.168.1.0", $user, $pw);
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <hr>
  
  <p><strong>Third...</strong></p>
  
  <pre><code>#!/usr/bin/perl
  
  use DBI;
  use DBD::ODBC;
  
  $user = "xxxx";
  $pw = "xxxx";
  
  my $dbh = DBI-&gt;connect("dbi:ODBC:tdsn", $user, $pw);
  </code></pre>
  
  <p><strong>.odbc.ini</strong></p>
  
  <pre><code>[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=
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>DBI connect('tdsn','xxxx',...) failed: (no error string) at ./teradata.pl line 13
  </code></pre>
  
  <hr>
  
  <p><strong>odbcinst.ini</strong></p>
  
  <pre><code>[ODBC DRIVERS]
  Teradata=Installed
  
  [Teradata]
  Driver=/usr/odbc/drivers/tdata.so
  APILevel=CORE
  ConnectFunctions=YYY
  DriverODBCVer=3.51
  SQLLevel=1
  </code></pre>