pyodbc encoding issue

Connectivity

pyodbc encoding issue

I have (what appears to be) an encoding issue using pyodbc -- Perl works without issue and is using the same ODBC drivers. 

---------------------------------------------------------------------

python code:

import pyodbc
pyodbc
.pooling = False
conn
= pyodbc.connect('DSN=tera01;', password=pw)

cursor
= conn.cursor()
cursor
.tables()
rows
= cursor.fetchall()

print(row[0].table_name) # Encoding??

扁牯䱴獩却獥楳湯

print(row[0].table_name.encode('utf_16_le'))

b'AbortListSession'

conn.execute("SELECT DISTINCT column FROM table;").fetchall()

Error: ('HY000', '[HY000] [unixODBC][Driver Manager]Driver returned SQL_ERROR or SQL_SUCCESS_WITH_INFO but no error reporting API found (0) (SQLExecDirectW)')

--------------------------------------------------------------------

It appears pyodbc is connecting because I can fetch table names, however, the table names are not encoded properly. Here is a list of things I've tried:

  1. Setting CHARSET/ENCODING in my DSN as 'ASCII', 'UTF-8', and many others
  2. Setting the locale:

    locale.setlocale(locale.LC_ALL, 'en_US.utf8')

  3. Changing autocommit and ANSI=True/False' in pyodbc.connect()

python==3.4.3, pyodbc==3.0.10

.odbc.ini:

[ODBC]
InstallDir=/opt/teradata/client/15.10/odbc_64
Trace=0
TraceDll=/opt/teradata/client/15.10/lib/odbctrac.so
TraceFile=/home/solberg/teratrace
TraceAutoStop=0

[ODBC Data Sources]
tera01
=Teradata ODBC Driver 15.10

[tera01]
Driver=/opt/teradata/client/15.10/lib64/tdata.so
DBCName=tera01
Username=solberg
Authentication=LDAP

.odbcinst.ini:

[ODBC DRIVERS]
Teradata=Installed

[ODBC Translators]
OEB to ANSI
=Installed

 

Tags (2)