sqlalchemy-teradata connection from python

Connectivity
Highlighted
Enthusiast

sqlalchemy-teradata connection from python

I have read through the "Teradata & SQLAlchemy: Introduction" article here: http://developer.teradata.com/tools/articles/teradata-sqlalchemy-introduction, and I can't seem to get a connection established to my Teradata database.

 

I am using my same credentials that I use to login from SQL Assistant. Here's the sample connection code from the article, changed for my database:

 

# SQLAlchemy Teradata connection attempt
from sqlalchemy import create_engine
user = 'my_userid'
pasw = 'my_pass'
host = '<System DSN Name>'

# connect
td_engine = create_engine('teradata://'+ user +':' + pasw + '@'+ host + ':22/')

# execute sql
sql = 'select top 100 * from mydb.mytable'
result = td_engine.execute(sql)

My database uses LDAP authentication, so I have tried my username as both 'my_userid' and 'my_userid@LDAP'. In addition, for the host I have tried using the full server name instead of the System DSN name.

 

 

When I use the full server name for host, I get the following error (regardless of how I input my_userid or my_userid@LDAP): "DatabaseError: (teradata.api.DatabaseError) (8017, '[28000] [Teradata][ODBC Teradata Driver][Teradata Database] The UserId, Password or Account is invalid. ')"

 

When I use the System DSN name for host, I get the following error (again regardless of my userid is input):  "DatabaseError: (teradata.api.DatabaseError) (10065, "[08001] [WSock32 DLL] 10065 WSA E HostUnreach: The Teradata server can't currently be reached over this network")"

 

I haven't been able to find any information yet that has helped me solve this, if anyone has any ideas I would appreciate the help.


Accepted Solutions
Teradata Employee

Re: sqlalchemy-teradata connection from python

I'm not sure how your connection string looks like but there was an issue that was about connecting with LDAP a while back: https://github.com/Teradata/sqlalchemy-teradata/issues/1. Can you try specifying your connection string like so and let me know what happens?

 

 

 

from sqlalchemy import create_engine
user = 'user'
pasw=user
host = 'host'

td_engine = create_engine('teradata://'+ user +':' + pasw + '@'+ host + '/' + '?authentication=LDAP')
print(td_engine)
Engine(teradata://user:***@host/?authentication=LDAP)

I prefer using github to manage issues related to sqlalchemy-teradata: https://github.com/Teradata/sqlalchemy-teradata/issues

1 ACCEPTED SOLUTION
3 REPLIES
Enthusiast

Re: sqlalchemy-teradata connection from python

Bump - anyone?

@Mark_Sandan?

Teradata Employee

Re: sqlalchemy-teradata connection from python

I'm not sure how your connection string looks like but there was an issue that was about connecting with LDAP a while back: https://github.com/Teradata/sqlalchemy-teradata/issues/1. Can you try specifying your connection string like so and let me know what happens?

 

 

 

from sqlalchemy import create_engine
user = 'user'
pasw=user
host = 'host'

td_engine = create_engine('teradata://'+ user +':' + pasw + '@'+ host + '/' + '?authentication=LDAP')
print(td_engine)
Engine(teradata://user:***@host/?authentication=LDAP)

I prefer using github to manage issues related to sqlalchemy-teradata: https://github.com/Teradata/sqlalchemy-teradata/issues

Enthusiast

Re: sqlalchemy-teradata connection from python

Yes, this worked for me. Thank you for the prompt response!