Teradata/PyTd

ODBC environment variable not set when using Teradata module from within Django?

Closed this issue · 3 comments

When using the teradata module under Django (or any other Python webapp/framework running under mod_wsgi) it is necessary to explicitly set the environment variable ODBC INI. The explaination for this is simple, our apache user does not have the ODBCINI=/opt/teradata/client/ODBC_64/odbc.ini variable set. Our linux configuration disencourages setting these kind of env-vars for system users. I've found a workaround for this issue: when setting it in the configuration of the framework or like so in the views.py (quick-n-dirty):

views.py:

from django.http import HttpResponse
import teradata
import os, sys

def index(request):
   os.environ["ODBCINI"] = "/opt/teradata/client/ODBC_64/odbc.ini"
   ...
   return HttpResponse(result_set)

Is it possible to integrate the ODBCINI variable in such a way that it is no longer needed to have the ODBCINI variable set in the web environm

I haven't been able to find a solution other than setting the environment variable. I have a question posted to the ODBC team to see if they know of another way.

Thanks Eric! Of course it is still always possible to set the variable in the general configuration files of the frameworks...

On Linux systems, the Python module loads "libodbc.so" from the system path by default. When loading this library, it is necessary to set the ODBCINI environment variable so that the Driver Manger can locate the Teradata ODBC driver.

If you tell the Python module to load the Teradata ODBC driver directly, you don't need to set the ODBCINI environment variable. You can do this by specifying the odbcLibPath argument in the UdaExec constructor or via the external configuration files. E.g.

udaExec = UdaExec(appName"HelloWorld", version="1.0", odbcLibPath="/opt/teradata/client/ODBC_64/lib/tdata.so")