0

I need to connect to the Teradata database using python. I have used the below code:

import pyodbc
import teradata



cnxn = pyodbc.connect('DRIVER={Teradata};SERVER=<*ServerName*>;DATABASE=<*Database Name*>;UID=<*User ID*>;PWD=<*Password*>',ansi=True, autocommit=True)

cur = cnxn.cursor()

But on executing, I am getting the error as :

Error: ('28000', '[28000] [Teradata][ODBC Teradata Driver] Not enough information to log on (0) (SQLDriverConnect); [28000] [Teradata][ODBC Teradata Driver] Not enough information to log on (0)')

What I am missing here ? What else needs to be included to set up the connection ?

Also, is there any other way to set up the connection. While looking, I have come across teradata.UdaExec(). Can this also be used?

2
  • 2
    The connectionstrings.com page here seems to suggest using DBCName= instead of SERVER=. Have you tried that? Commented Jan 31, 2017 at 18:49
  • are you connecting from a Linux server? Commented Feb 2, 2017 at 10:48

1 Answer 1

1

The following works in CentOS Linux server.

create a file with the below contents in any file (say odbc.ini)

[ODBC Data Sources]
my_data_source=tdata.so

[my_data_source]
Driver=/path/to/teradata/drivers/tdata.so
DBCName=<td_hostname>
LastUser=<user_name>
Username=<user_name>
Password=<password>
Database=<default_database>
DefaultDatabase=<default_database>
TDMSTPortNumber=<teradata_port>

set ODBCINI variable to the path of the odbc file

export ODBCINI=/file/to/path/of/odbc.ini

note: you can skip the setting of ODBCINI env variable by creating the odbc.ini file in the home directory i.e. /home/user/.odbc.ini (note that the .odbc.ini is a hidden file with a dot prefix in the file name)

now to connect to Teradata use the below snippet.

import pyodbc
pyodbc.pooling = False
conn = pyodbc.connect('DSN=my_data_source',ansi=True, autocommit=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.