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:
try:
msg=open("myFile.log", 'r')
a=msg.read(20)
strInsert = "INSERT INTO APPLI.ALERT(ID_ALERT,MESSAGE,TYPE_ALERT) values(1625.0,'"+a.replace('\"','').decode('utf-8')+"',3)"
logger_module.debug(str(strInsert))
SdeExecuteSQL(CONNEXION_FILE,strInsert )
except:
python_error_handler()
When I open myFile.log with Notepad++ the encoding is ANSI as UTF-8.
Do you have any hint?