Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 = "" 
arcpy.ClearWorkspaceCache(r"SDEConnection")
print arcpy.GetMessages() + "\n"

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

share|improve this question
1  
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
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. –  RyanDalton 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
show 1 more comment

1 Answer

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"
arcpy.ClearWorkspaceCache_management()

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

share|improve this answer
add comment

Your Answer

 
discard

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.