Re: [cx-oracle-users] Can't have access to a corrupted VARCHAR2.
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2018-03-19 21:44:36
|
Hi, As Walter mentioned, you can set the environment variable NLS_LANG or you can set the encoding parameter when you create the connection. The latter is usually preferable and easier to use. For example: cx_Oracle.connect("user/pw@dsn", encoding = "WINDOWS-1252", nencoding = "UTF-8") This will ensure that all data is encoded using the actual database character set. If you use something different you do run the risk of getting encoding errors, and currently there is no way in cx_Oracle to specify the "errors" parameter to the decode() that takes place internally. That could be an enhancement request. Feel free to log such a request on the issues page: https://github.com/oracle/python-cx_Oracle/issues. It might also be useful to include information on the character sets in use in your database by posting the results of this query: select * from nls_database_parameters where parameter in ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET'); Anthony On Fri, Mar 16, 2018 at 7:58 AM, Stéphane JULIEN <ste...@ju...> wrote: > Hello, > > I have a WINDOWS-1252 (cp1252) encoded Oracle database. A 6.2.1 cx_Oracle > and a Python 3.6.4 distribution on Wondows. > > In some VARCHAR2 record of a table, I have corrupted data. When I try to > select such records, I have : > > 'charmap' codec can't decode byte 0x90 in position 36: character maps to > <undefi > ned> > (<class 'UnicodeDecodeError'>, UnicodeDecodeError('charmap', b'ELLE > REVIENDRA VE > RS NOUS - BIEN PLAC*\x90*\xc9S - ELLE ATTEND SON CLIENT', 36, 37, > 'character maps > to <undefined>'), <traceback object at 0x0000000003C6B5C8>) > > The \x90 character is not allowed in cp1252 encoding. Where cx_Oracle > tries to convert to unicode, there is an exception. I suppose that a strict > decode is used. > > I can't find a way to prevent or detect the crash. I can't event find a > way to detect the key of the corrupted record. > > Is there a way to do a *decode(..., 'IGNORE')* in my Python Program or to > receive the binary data like in Python 2 ? > > I thank you for your help. > > Best wishes. > Stéphane > > > ------------------------------------------------------------ > ------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > |