I have a simple python script that reads a string from a text file and inserts it into an Oracle database.

When I run the script with Eclipse using Pydev plugin I get no error and the message is inserted into database.

However, when I run the script using an ArcGIS geoprocessing service (using a toolbox), I get the following error in the logs, and no insertion is performed into database:

[06/09/2013-10:30:39.380] ERROR - APPLICATION <module>(<type 'exceptions.UnicodeEncodeError'>, UnicodeEncodeError('ascii', u"INSERT INTO APPLI.ALERT (ID_ALERT,MESSAGE,TYPE_ALERT) values(1617.0,q'[Les coordonn\xe9es ne sont pas correctes\n]',3)", 94, 95, 'ordinal not in range(128)'))

The code is the following:

    msg=open("myFile.log", 'r')
    strInsert = "INSERT INTO  APPLI.ALERT(ID_ALERT,MESSAGE,TYPE_ALERT) values(1625.0,'"+a.replace('\"','').decode('utf-8')+"',3)"
    SdeExecuteSQL(CONNEXION_FILE,strInsert )

When I open myFile.log with Notepad++ the encoding is ANSI as UTF-8.

Do you have any hint?


I found the answer: The problem comes from logger_module.debug(str(strInsert)) I deleted str() and everything runs correctly now with logger_module.debug(strInsert)

Do you have any idea why it worked in Eclipse but not in ArcGIS Server?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.