Hi All,
I'm running ibm_db_dbi version 2.0.5.9 and python 3.6.8:
Code has been installed/updated via the opensource option on the ACS tools
menu.
The python code is running in a virtual environment created with the
--system-site-packages flag to get access to the base install of ibm_db_dbi
and itoolkit
In the virtual environment:
<pip list>
Package Version
---------- -------
ibm-db 2.0.5.9
itoolkit 1.5.1
pip 19.0.3
setuptools 40.6.2
six 1.10.0
wheel 0.29.0
XlsxWriter 1.0.7
<python -V>
Python 3.6.8
I'm in the UK where most of our character data is set or defaults to CCSID
285.
My simple DB2 Table to excel spreadsheet utility, written in python, failed
the other day with a UnicodeDecodeError.
The error appears to be occurring due to the presence of the pound sign
character (£) in a column name.
I ran a few tests and it appears to me that:
- £ gets handled OK as data in the table
- £ gets handled OK as Column Heading Text
- £ gets handled OK as Field Text
- £ DOES NOT get handled ok as part of the Column Name e.g INFORA£.
As a minimal code example in the REPL
import ibm_db_dbi as dbi
conn = dbi.connect()
cur = conn.cursor()
cur.execute('select * from richarc.stuff')
True
cur.description
Traceback (most recent call last):
File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line
1062, in __get_description
column_index))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 4:
ordinal not in range(128)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/QOpenSys/pkgs/lib/python3.6/site-packages/ibm_db_dbi.py", line
1111, in __get_description
raise self.messages[-1]
ibm_db_dbi.Error: ibm_db_dbi::Error: UnicodeDecodeError('ascii',
b'DATA\xc2\xa3', 4, 5, 'ordinal not in range(128)')
cur.messages
[Error("UnicodeDecodeError('ascii', b'DATA\\xc2\\xa3', 4, 5, 'ordinal not
in range(128)')",)]
Is this a known problem?
thanks kindly,
Craig
As an Amazon Associate we earn from qualifying purchases.