I'm just starting out with ArcPy and ArcSDESQLExecute.
I'm trying to use the 'Execute a list of SQL statements' ArcPy script from http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z00000021000000.htm
import arcpy from arcpy import env import sys try: # Make data path relative # env.workspace = sys.path # Two ways to create the object, which also creates the connection to ArcSDE. # Using the first method, pass a set of strings containing the connection properties: # <serverName>,<portNumber>,<version>,<userName>,<password> # sdeConn = arcpy.ArcSDESQLExecute("gpserver3","5151","#","toolbox","toolbox") # Using the second method pass the path to a valid ArcSDE connection file # sdeConn = arcpy.ArcSDESQLExecute(r'Database Connections\GIS_Connection.sde') # Get the SQL statements, separated by ; from a text string. # SQLStatement = arcpy.GetParameterAsText(0) SQLStatementList = SQLStatement.split(";") print "+++++++++++++++++++++++++++++++++++++++++++++\n" # For each SQL statement passed in, execute it. # for sql in SQLStatementList: print "Execute SQL Statement: " + sql try: # Pass the SQL statement to the database. # sdeReturn = sdeConn.execute(sql) except Exception, ErrorDesc: print ErrorDesc sdeReturn = False # If the return value is a list (a list of lists), display each list as a row from the # table being queried. if isinstance(sdeReturn, list): print "Number of rows returned by query: " + len(sdeReturn), "rows" for row in sdeReturn: print row print "+++++++++++++++++++++++++++++++++++++++++++++\n" else: # If the return value was not a list, the statement was most likely a DDL statment. # Check its status. if sdeReturn == True: print "SQL statement: " + sql + " ran sucessfully." print "+++++++++++++++++++++++++++++++++++++++++++++\n" else: print "SQL statement: " + sql + " FAILED." print "+++++++++++++++++++++++++++++++++++++++++++++\n" except Exception, ErrorDesc: print Exception, ErrorDesc except: print "Problem executing SQL."
I'm getting this error: " 'ascii' codec can't encode character u'\udf9c' in position 52: ordinal not in range(128)"
What have I done wrong? I don't know if it's a problem with the ascii formatting in the script, or if the SQL statement needs to be put in the script somewhere, or if it's something else?