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
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.