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

| improve this question | | | | |
  • 1
    I don't know much about that particular arcpy command, but it's probably a 32/64bit issue. Do you have the 64bit client libs installed on your server machine? Give a read of this: resources.arcgis.com/en/help/main/10.1/index.html#//… noting the 64bit libraries required for server – KHibma Feb 16 '15 at 4:05
  • this was definitely the cause, I was missing the client libraries completely :) Installed them in the bin directory of ArcGIS Server and everything started working. If you put your comment in as an answer I'll accept it, thanks! :) – Lars Anundskås Feb 16 '15 at 20:33

Desktop is a 32bit application, thus 32bit client libs are required when connecting to the database.

ArcGIS Server is 64bit. The 64bit client libs need to be installed for the service to work. The particular help link for Postgres client libs can be found here

| improve this answer | | | | |

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.