AnsweredAssumed Answered

Has anyone got a py script that will find, iterate and delete all versions within an Enterprise GDB?

Question asked by ben_vk on Nov 24, 2014
Latest reply on Jan 22, 2015 by ben_vk

I am currently running the below code to delete all versions before doing a weekly compress. But as you can see it is very primative and the hard coding of the names is becoming annoying as I am having to edit it each time a GIS User starts or leaves our buisness.

 

Is there a simple tool that will find/list all versions? That way I can then go ahead and delete them once a list has been created.

 

# Name: DeleteAllVersion.py
# Description: Deletes all versions from our SDE
# By Ben Van Kesteren 22/07/2014

# Import system modules
import arcpy

# Set local variables
inWorkspace = r"Database Connections/GISADMIN@SDE_Spatial@Smithy.sde"
Nathan = "Nathan"
Ben = "Ben_Edit"
David = "David_Armstrong"
James = "James"
Patrick = "Patrick"
Rory = "Rory"
Josh = "Josh"
MrsBeer = "Mrs_Beer_Edit"
#Russell = "Muddy_Edit"
Patrea = "Patrea"
Kerrie = "Kerrie"
SteveM = "Steve_Edit"
Helen = "Helen"
MattJ = "Matt_Johnson"

# Execute DeleteVersion
arcpy.DeleteVersion_management(inWorkspace, Nathan)
arcpy.DeleteVersion_management(inWorkspace, Ben)
arcpy.DeleteVersion_management(inWorkspace, David)
arcpy.DeleteVersion_management(inWorkspace, James)
arcpy.DeleteVersion_management(inWorkspace, Patrick)
arcpy.DeleteVersion_management(inWorkspace, Rory)
arcpy.DeleteVersion_management(inWorkspace, Josh)
arcpy.DeleteVersion_management(inWorkspace, MrsBeer)
#arcpy.DeleteVersion_management(inWorkspace, Russell)
arcpy.DeleteVersion_management(inWorkspace, Patrea)
arcpy.DeleteVersion_management(inWorkspace, Kerrie)
arcpy.DeleteVersion_management(inWorkspace, SteveM)
arcpy.DeleteVersion_management(inWorkspace, Helen)
arcpy.DeleteVersion_management(inWorkspace, MattJ)

Outcomes