0
votes

Sorry in advance, I am very new to Python. I am trying to connect to a Teradata database via python sqlalchemy, however I can't successfully establish a connection.

The error message I receive is "NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:teradata".

Here is what I have so far:

import sqlalchemy

from sqlalchemy import create_engine
user = 'myusername'
pasw= 'mypassword'
host = 'hostname.com'
db = 'PRD_DB_SCHEMA'
engine_str = ("teradata://"+user+":"+pasw+"@"+host+":22/"+db+"?authentication=LDAP")
td_engine = create_engine(engine_str)
conn = td_engine.connect()
2

2 Answers

1
votes

For teradatasql, set logmech instead of authentication:

teradatasql://{user}:{password}@{host}/?logmech=LDAP?driver=teradata

Reference: https://pypi.org/project/teradatasqlalchemy/

EDIT: Actually, driver is not necessary:

teradatasql://{user}:{password}@{host}/?logmech=LDAP
0
votes

Sorry, I just solved this:

engine_str = ("teradata://"+user+":"+pasw+"@"+host+"/?authentication=LDAP?driver=Teradata")