I am trying to connect to Teradata using cx_Oracle in Python.
import cx_Oracle import psycopg2
connection = 'user/hostname/password' con = cx_Oracle.connect(connection)
getting the error: net service name is incorrectly specified
CodePudding user response:
Teradata has its own driver, cx_Oracle is used to connect to Oracle databases. I think (I'm not sure, I don't have experience with Teradata databases, but this is what Teradata documentation states) that the driver you need is teradatasql: pip install teradatasql
CodePudding user response:
This is how I connect to Teradata with Python
import sqlalchemy.engine import create_engine
engine_str = (f"teradatasql://{username}:{password}@{host}/")
pd.read_sql_query(query, engine_str)
sqlalchemy does, however, require you to have the teradata dialect installed as well.
pip install teradatasqlalchemy