Teradata / PyTd

A Python Module to make it easy to script powerful interactions with Teradata Database in a DevOps friendly way.
MIT License
108 stars 43 forks source link

Teradata Python module Picking up incorrect odbc #62

Closed clydewatts closed 7 years ago

clydewatts commented 7 years ago

I am running the below python script , windows 7 , Teradata vm , TTU 15.10. python 3.5.2 , latest Teradata python module import teradata udaexec = teradata.UdaExec(appName="Test", version=1) s = udaexec.connect(method='ODBC',system='192.168.88.136',username='dbc',password='dbc') and getting error teradata.api.DatabaseError: (0, '[08001] [TPT][ODBC SQL Server Wire Protocol driver]Invalid Connection Data., [TPT][ODBC SQL Server Wire Protocol driver]Invalid attribute in connection string: DBCNAME.') 2016-12-18 13:43:18,217 - teradata.udaexec - ERROR - Uncaught exception Traceback (most recent call last):

To fix I do the following Specify the dsn=xxxxx, import teradata udaexec = teradata.UdaExec(appName="Test", version=1) s = udaexec.connect(method='ODBC',system='192.168.88.136',username='dbc',password='dbc',dsn="PRIMARK")

escheie commented 7 years ago

Could you please post the logs from your connection attempt, particularly the lines that output the available drivers?

2016-12-19 18:13:17,669 - teradata.tdodbc - INFO - Available drivers: SQL Server, Teradata, Teradata Database ODBC Driver 16.00
2016-12-19 18:13:17,669 - teradata.tdodbc - WARNING - More than one driver found for 'Teradata'.  Using 'Teradata Database ODBC Driver 16.00'.  Specify the 'driver' option to select a specific driver.
clydewatts commented 7 years ago

Test.20161218134804-2.txt

clydewatts commented 7 years ago

Made a temp change to the code to get the first driver instead of the last. Not sure if that is the best solution. It does seem to work. This seems to happen on all windows pc's( all are windows 7) that I have installed TTU 15.10.

def determineDriver(dbType, driver): retval = driver if driver is not None: if driver not in drivers: raise InterfaceError( "DRIVER_NOT_FOUND", "No driver found with name '{}'. " " Available drivers: {}".format(driver, ",".join(drivers))) else: matches = [] for driver in drivers: if dbType in driver: matches.append(driver) if not matches: raise InterfaceError( "DRIVER_NOT_FOUND", "No driver found for '{}'. " "Available drivers: {}".format(dbType, ",".join(drivers))) else:

retval = matches[len(matches) - 1]

        retval = matches[0]
        if len(matches) > 1:
            logger.warning(
                "More than one driver found "
                "for '{}'.  Using '{}'."
                "  Specify the 'driver' option to "
                "select a specific driver.".format(dbType, retval))
return retval
jackalwoods commented 7 years ago

I have downloaded latest version but getting the same error.

session = udaExec.connect(method="odbc", system="192.168.252.128", username="dbc", password="dbc");

Error: DatabaseError: [HY000] [TPT][ODBC MySQL Wire Protocol driver]Insufficient information to connect to the data source., [TPT][ODBC MySQL Wire Protocol driver]Invalid attribute in connection string: DBCNAME.

Please suggest. Do I need to provide DSN? And where do I find it?

hhoeck commented 7 years ago

Obviously the wrong ODBC driver is taken, you should invest in an additional parameter driver="Teradata"