I'm trying to connect to a postgresql database using ARCSDESQLExecute from ArcPy. When running my script as stand alone (debug from pyscripter) it works fine. When running my script as a tool from ArcMap it works fine.
I am able to publish the tool as a GPTool and to view the test-form from the rest interface. When running the tool from the rest interface, it fails with:
sde_conn = arcpy.ArcSDESQLExecute("localsrv", "5432", "", "myusername", "mypassword") File "c:\program files\arcgis\server\arcpy\arcpy\arcobjects\mixins.py", line 893, in __init__ _BaseArcObject.__init__(self, *gp_fixargs((server, instance, database, user, password), True)) File "c:\program files\arcgis\server\arcpy\arcpy\arcobjects\_base.py", line 47, in __init__ for arg in args)) RuntimeError: Object: Connection error Operation Failed Failed to execute (MyGPTool). Failed to execute
I have also tried this:
sde_conn = arcpy.ArcSDESQLExecute("localsrv", "5432", "mydatabase", "myusername", "mypassword")
When I try to use an .sde file for arcpy.ArcSDESQLExecute i get the same error. When trying to connect to a MSSQL server, it does not crash, only connecting to postgresql server fails.
I have tried to publish it on two different arcgis servers, same behavior. Arcgis server versions tested: 10.2 and 10.1.1