Hi All,
I am trying to use arcpy on ArcCatalog 10.2.1 to delete some version on our sql database. when I use the function arcpy.DeleteVersion_management(connection, version.name), i get an error "ERROR 000301: The workspace is of the wrong type". The connection is to a .sde file and the user has permission to delete all versions.
Thank you for your help
Below is my script:
arcpy.env.Workspace = r'C:\Users\JBurgos\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\ArcGIS to BELNetwork.sde'
defaultVersion = "sde.DEFAULT"
connection = arcpy.env.Workspace
versionName = "WR456_DN560"
arcpy.ClearWorkspaceCache_management()
# Execute DeleteVersion
for version in arcpy.da.ListVersions(connection):
try:
print "Found - {0}".format(version.name.split(chr(34) + ".")[1])
currentversion = format(version.name.split(chr(34) + ".")[1])
except:
try:
print "Found - {0}".format(version.name.split(".")[1])
currentversion = format(version.name.split(".")[1])
except:
print "Found - {0}".format(version.name.split(".")[0])
currentversion = format(version.name.split(".")[0])
if currentversion == versionName:
print("Attempting to Delete version {0}".format(version.name))
arcpy.DeleteVersion_management(connection, version.name)
print("Deleted version {0}".format(version.name)) Print ("Done")