Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :(

share|improve this question
Where did you get the sample from? Providing a link would be helpful. – RyanDalton 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
@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. – RyanDalton Sep 13 '12 at 20:28
It appears that ESRI have corrected the code in the 10.1 example:… – 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.