I am getting strange error while trying to connect to Teradata from Python Pyodbc.
The code i used
import pyodbc
pyodbc.pooling=False
conn=pyodbc.connect('DRIVER={
TeradataDriver16.20};DBCNAME=DBCNAME;UID=user_id;
PWD=Password;QUIETMODE=YES;database=databse;')
The above connection is successful. Now I am trying to run the below query
cursor = conn.cursor()
cursor.execute("SELECT TOP 10 * FROM DB_NAME")
tables = cursor.fetchall()
This results in following error
Error: ('HY000', '[HY000] 䑛瑡䑡物捥嵴佛䉄⁃楬嵢唠楮潣敤挠湯敶瑲牥戠晵敦\u2072
癯牥汦睯\x00\x000\x00\x00\x00\x00\x00\x00\x00\x00\x00[\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00(\x00\x00\x00 (0) (SQLExecDirectW)')
Any pointers in solving this would be appreciated.
I cannot recreate your error with pyodbc. Could you try Teradata's own official package 'teradata' and see if you get similar behaviour.
pip install teradata
And then
import teradata
udaExec = teradata.UdaExec (appName="HelloWorld", version="1.0",
logConsole=False)
with udaExec.connect(method="odbc",system=DBCNAME,
driver="TeradataDriver16.20",
database=DBCNAME, username=user_id,
password=Password) as session:
for row in session.execute("SELECT TOP 10 * FROM DB_NAME"):
print(row)
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.