arcgis python delete all data in a database

# -*- coding: cp936 -*-
import xlrd # must init xlrd
import arcpy
import os

def main():
    arcpy.env.workspace =gdbFile
    datasets = arcpy.ListDatasets()
    for dataset in datasets:
        arcpy.AddMessage(u"gisoracle删除数据集"+dataset)
        arcpy.Delete_management(dataset,"FeatureDataset")

    featureclasses = arcpy.ListFeatureClasses()
    for fc in featureclasses: 
        arcpy.AddMessage (U " gisoracle delete feature class " + fc) 
        arcpy.Delete_management (fc) 

    the Tables = arcpy.ListTables ()
     for the Table in the Tables: 
        arcpy.AddMessage (U " gisoracle Delete table " + the Table) 
        ArcPy. Delete_management (the Table) 

    of Rasters = arcpy.ListRasters ()
     for raster in of Rasters: 
        arcpy.AddMessage (U " gisoracle delete grid " +  raster)
        arcpy.Delete_management (raster)

gdbFile = arcpy.GetParameterAsText(0) #gdb


try:
    main()
    #arcpy.SetParameterAsText(3, inFeature)  # Is polygon
except Exception, ErrorDesc:
    arcpy.AddError(u"错误:"+str(ErrorDesc))

 

Guess you like

Origin www.cnblogs.com/gisoracle/p/11361010.html