getting the error while reading data from DB2 table using PYTHON 3.x.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 10: ordinal not in range(128)
getting the error while reading data from DB2 table using PYTHON 3.x.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 10: ordinal not in range(128)
By default, both Python and your ODBC driver are looking at your locale settings in Linux to determine your default encoding.
First, set your locale settings as follows:
export LC_ALL=C.UTF-8
Second, instead of using string literals in your SQL queries, use parameters:
for example, change
c.execute("INSERT INTO table (data) VALUES ('non-ascii stuff')"
to
c.execute("INSERT INTO table (data) VALUES (?)", ['non-ascii stuff'])