I am using Python 3.3 on Windows 7x64 machine to connect to an Oracle server over the VPN tunnel to dump locally data in a CSV file. I am using cx_Oracle module to connect to Oracle. Everything is fine until the cursor hits a character in some string column, which causes the module to fail with error:
for row in orcl_cur.execute(sql_select):
File "C:\Python33\lib\encodings\cp1252.py", line 15, in decode
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 426: character maps to <undefined>
AT this point the dump stops to whatever rows were saved so far.
How can I avoid this?
Another possibility is that the database should contain the cp1252, but there is a bug in the data.
If you need to solve the situation, you can wrap the decoding of the character the try-except construct, replace the character by something or very visible (to be able to see the problem) or by something very invisible (to mask the problem). You can also write some warning into a log in the case.
It is difficult to say without seeing something more.