Sahil Taneja
Sahil Taneja

Reputation: 3

(DRIVER_NOT_FOUND', "No driver found for 'Teradata'. Available drivers:) - using Anaconda-Jupyter notebooks with teradata module

I have been using Anaconda-Jupyter notebooks with python version 3.5.4. The objective was to create the connection string in order to connect the Anaconda-Jupyter notebooks Python with Teradata DB. After installing the teradata python package, I got some error stating that ('DRIVER_NOT_FOUND', "No driver found for 'Teradata'. Available drivers: ").

I need this connection string in order to get the tables from the teradata DB along with data. I have already installed ODBC Driver and created an odbc.ini file. But still, I'm getting this Driver not found error Jupiter notebook. Please, help me out. Below is the script, which I'm using for making connection string.

Please let me know to what to be write in system,host,dsn,username,password. and what will be the driver name for teradata database. They need to be mention in this script:

udaExec.connect(method="odbc",system=host, username=username,
                            password=password, driver="DRIVERNAME")

PS: The Anaconda-Jupyter Notebook server is running on Unix.

Script:

#Using teradata module
#You can install teradata via PIP: pip install teradata
#to get a list of your odbc drivers names, you could do: teradata.tdodbc.drivers

import teradata
import pandas as pd

host,username,password = 'HOST','UID', 'PWD'
#Make a connection
udaExec = teradata.UdaExec (appName="test", version="1.0", logConsole=False)


with udaExec.connect(method="odbc",system=host, username=username,
                            password=password, driver="DRIVERNAME") as connect:

    query = "SELECT * FROM DATABASEX.TABLENAMEX;"

    #Reading query to df
    df = pd.read_sql(query,connect)

# do something with df,e.g.
print(df.head()) #to see the first 5 rows

Thanks!

Upvotes: 0

Views: 5530

Answers (2)

Anton Georgiev
Anton Georgiev

Reputation: 1

This fixed the issue for me:

from sqlalchemy import create_engine
import sqlalchemy_teradata

def connect_td_engine():
    user='YOUR_USER'
    pasw="YOUR_PASSWORD'
    host = 'YOUR_HOST.COM'
    engine = create_engine(f'teradatasql://{host}/?user={user}&password={pasw}')
    return engine

Simply imporing the sqlalchemy_teradata fixes the problem and no longer requires the driver.

Upvotes: 0

rohan goli
rohan goli

Reputation: 146

  1. You need to install Teradata ODBC drivers(https://downloads.teradata.com/download/connectivity/odbc-driver/linux) and export path for ODBC home. [ https://github.com/Teradata/PyTd/issues/104 ]

  2. Or directly use teradatasql python pip package to execute the sql queries as cursors(viz., mysql-python) [ https://pypi.org/project/teradatasql/ ]

Upvotes: 0

Related Questions