I want to be able to control connections to ArcSDE via python. Here is my script so far using ESRI's example.

import arcpy
from arcpy import env
env.workspace = r"SDEConnection" 
fcList = arcpy.ListFeatureClasses()
print str(fcList) + "\n"
env.workspace = "" 
print arcpy.GetMessages() + "\n"

But this isnt working .. it crashes my Python window :(

  • 1
    Where did you get the sample from? Providing a link would be helpful. – RyanKDalton Sep 13 '12 at 15:27
  • And i just noticed the syntax in that site says ClearWorkspaceCache_management.. but in the example it doesnt.. hmm im going to try with the 'management' on the end now.. i will let you know what the outcome is – Kam Sep 13 '12 at 15:47
  • 3
    @Kam- Since you answered your own question, please put the above comment into the answer area and, in a couple of days, you should be able to mark your question as accepted. I would suggest updating your code with the corrected syntax. – RyanKDalton Sep 13 '12 at 20:28
  • 1
    It appears that ESRI have corrected the code in the 10.1 example: resources.arcgis.com/en/help/main/10.1/index.html#//… – Fezter Sep 14 '12 at 1:19

According to the updated help, you need to use arcpy.ClearWorkspaceCache_management()

You can use the following code:

import arcpy
from arcpy import env
env.workspace = "c:/connectionFiles/Connection to gpserver.sde"

This answer has been derived from OP's comment on the question.

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.