Python odbc not returning Teradata errors

Connectivity
Teradata Employee

Python odbc not returning Teradata errors

I have a frustrating issue with ODBC in linux redhat.

I can run SQL and get accurate error messgaes from Teradata sample testing program using ODBC.

But when I use python or isql, odbc driver manager complain and returned a generic error message.

Below is a python example:

[etl_adhoc@vpit2 ~]$ python

Python 2.7.1 (r271:86832, Apr 25 2011, 13:28:14)

[GCC 4.5.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import pyodbc

>>> connection = pyodbc.connect("DSN=testdsn",ansi=True)

>>> cursor = connection.cursor()

>>> cursor.execute("select count(*) cnt from BERUBE.dim_day")

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

pyodbc.Error: ('HY000', '[HY000] [unixODBC][Driver Manager]Driver returned SQL_ERROR or SQL_SUCCESS_WITH_INFO but no error reporting API found (0) (SQLExecDirectW)')

What is wrong with my config to disable API to returned the real TD error which shall be:

{error} STATE=42S02, CODE=4294963494, MSG=[Teradata][ODBC Teradata Driver][Teradata Database] Database 'BERUBE' does not exist.

5 REPLIES
Enthusiast

Re: Python odbc not returning Teradata errors

I don't get that sort of error, but have you tried:

a) a DSNLess connection.  See http://code.google.com/p/pyodbc/wiki/ConnectionStrings

cnxn = pyodbc.connect('DRIVER=Teradata;DBCNAME=host;UID=user;PWD=password;', autocommit=True)

b) don't specify ansi=True.

I typically use the format in a), but I also add QUIETMODE=YES.

Fan

Re: Python odbc not returning Teradata errors

How does the DSNLess connection help in such a case?

After playing around more with the odbc drivers, I'm able to display the correct Teradata error message but cannot connect to MySQL within one python script.

Basically we want to connect to both MySQL and Teradata in one session.

Any ideas how we can achieve that?

Thanks.

Re: Python odbc not returning Teradata errors

Simony,

Do you recall what you did in order to get the correct Teradata error messages to display? I'm hitting the same problem right now, so any help would be appreciated!

Teradata Employee

Re: Python odbc not returning Teradata errors

Please note unixODBC driver manager is not supported by Teradata to use with Teradata ODBC driver.

Teradata Employee

Re: Python odbc not returning Teradata errors


Simony,


Do you recall what you did in order to get the correct Teradata error messages to display? I'm hitting the same problem right now, so any help would be appreciated!