此工具仅适用于企业级地理数据库工作空间。
清除企业级地理数据库工作空间缓存中的全部企业级地理数据库工作空间
arcpy.ClearWorkspaceCache_management()
# -*- coding: utf-8 -*- import arcpy import os from arcpy import env arcpy.ClearWorkspaceCache_management() env.workspace = 'Database Connections\Connection to 10xxx118.sde' edit = arcpy.da.Editor(arcpy.env.workspace) edit.startEditing(False, True) edit.startOperation() gdb=r'D:\test22\sde2.gdb' datasets = arcpy.ListDatasets("*", "Feature") for ds in datasets: fcs=arcpy.ListFeatureClasses(feature_dataset=ds) for fc in fcs: with arcpy.da.InsertCursor(fc, ["SHAPE@","NAME"]) as cur2: with arcpy.da.SearchCursor(os.path.join( gdb,ds.replace('Estimate.DBO.','').replace('estimate.DBO.',''), fc.replace('Estimate.DBO.','').replace('estimate.DBO.','')), "SHAPE@") as cur3: for row in cur3: cur2.insertRow([row[0],'aa']) edit.stopOperation() edit.stopEditing(True)