Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column name decoding issue in DB2 with unixodbc #512

Closed
guardhunt opened this issue Jan 18, 2019 · 3 comments
Closed

Column name decoding issue in DB2 with unixodbc #512

guardhunt opened this issue Jan 18, 2019 · 3 comments

Comments

@guardhunt
Copy link

guardhunt commented Jan 18, 2019

I am getting column name decoding issues very similar to several other tickets that I have looked at. I have tried all the solutions offered in those cases, specifically #194, #498 and #205.

Environment

  • Python: 3.6
  • pyodbc: 4.0.25
  • OS: linux/docker (3.6-slim-streatch)
  • unixodbc: 2.3.7
  • DB: DB2 for i, version 7.2
  • driver: iSeries Access ODBC Driver

Running a python 3.6 docker container, connecting to db2 with the current unixodbc version. I am not able to use the ibm_db library at the moment due to licensing.

Issue

As with the other related tickets, the return column names from the cursor descriptor on SQL select calls is returning encoded.

Everything works fine connecting from windows, so I suspect it has to do with pyodbc interfacing with unixodbc.

Last attempted encoding setup:

connection.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
connection.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
connection.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-32le')

some encoding type cases

  • The above options throw: UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 8-11: code point not in range(0x110000)
  • encoding='utf-32be' on the meatadata gives me: UnicodeDecodeError: 'utf-32-be' codec can't decode bytes in position 0-3: code point not in range(0x110000)
  • encoding='utf-16be' on the metatdata gives me: UnicodeDecodeError: 'utf-16-be' codec can't decode bytes in position 34-35: illegal encoding
  • encoding='utf-16le' on the metatdata gives me: 'C\x00喷\x00㺘冓翿\x00\x00\x00\x00\x00㤶䎞罓' (a sample col name that is being returned)
@guardhunt
Copy link
Author

guardhunt commented Jan 18, 2019

If it helps, my (partially redacted) odbc.ini is below. I have tried many variations of graphic, force traslation, and uncodesql options so far just in case.

[SampleDSN]
Description = primary
Driver = iSeries Access ODBC Driver
System = sample_sys
UserID = sample_us
Password = sample_pw
Naming = 1
DefaultLibraries = QGPL
Database = sample_db
ConnectionType = 0
CommitMode = 2
ExtendedDynamic = 0
DefaultPkgLibrary = QGPL
DefaultPackage = A/DEFAULT(IBM),2,0,1,0,512
AllowDataCompression = 1
LibraryView = 0
AllowUnsupportedChar = 0
ForceTranslation = 0
Trace = 0
GRAPHIC=1
UNCODESQL=1

@v-chojas
Copy link
Contributor

Please post an ODBC trace.

@guardhunt
Copy link
Author

Found the issue. Closing. The issue had to do with the drivers I was using with IBM. Using a newer driver fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants