What is the python command for deleting a GlobalID-based relationship class?

11-01-2017 10:11 AM
New Contributor II

I have two feature classes (wControlValve and wBlowOff) that I need to drop and recreate weekly (part of a migration of data from Smallworld to ESRI). Once they're recreated, I create an ObjectID-based relationship class which I then migrate to a GlobalID-based relationship class. I successfully created it once. The problem is I can't delete it in order to recreate it every week!  I've tried right-clicking it and choosing "Delete" which always appears to be successful - at first - but then when I refresh, the relationship class is still there.  I also haven't been able to delete it via python (which is actually how I need to accomplish it). I've tried when everyone is off but me (as sde - see attachment), but still get the lock message. Any ideas?


>>> arcpy.env.workspace = "Database Connections/aoprod-sde.sde"

>>> arcpy.Exists('gis.sde.wControlValve_wBlowOff')


>>> arcpy.Delete_management('gis.sde.wControlValve_wBlowOff')

Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 4341, in Delete raise e ExecuteError: ERROR 000601: Cannot delete Database Connections/aoprod-sde.sde\gis.sde.wControlValve_wBlowOff. May be locked by another application. Failed to execute (Delete).


Tags (1)
0 Kudos
1 Reply
MVP Legendary Contributor

There is no tool in the arcpy tree in Pro or *Map.

If there is a tool that you use to do this in ArcToolbox, then check the code example for it.  I suspect that there are a number of things that need to be done before locks are released on any file and they may not involve functionality that isn't available as a tool or an arcpy function

0 Kudos