# L_COMM_INFO CIDList = [] S_POL_AR = os.path.join(FRIS_FGDB, "S_POL_AR") S_POL_ARTable = arcpy.SearchCursor(S_POL_AR) for ID in S_POL_ARTable: FIELD = "CID" Val = ID.getValue(FIELD) CIDList.append(Val) NewCIDList = list(set(CIDList)) L_COMMUNITY_INFO = "Database Connections\NC_FLOOD.sde\NC_FLOOD.DBO.L_COMMUNITY_INFO" L_COMMUNITY_INFOView = os.path.join(FRIS_FGDB, "L_COMM_INFOView") L_COMMUNITY_INFOTable = os.path.join(FRIS_FGDB, "L_COMM_INFO") arcpy.TableToTable_conversion (L_COMMUNITY_INFO, FRIS_FGDB, "L_COMM_INFO") arcpy.TruncateTable_management (L_COMMUNITY_INFOTable) arcpy.MakeTableView_management (L_COMMUNITY_INFO, L_COMMUNITY_INFOView) for ITEM in NewCIDList: CLAUSE = ("{0} = '{1}'".format ("CID", ITEM)) arcpy.SelectLayerByAttribute_management (L_COMMUNITY_INFOView, "NEW_SELECTION", CLAUSE) arcpy.Append_management (L_COMMUNITY_INFOView, L_COMMUNITY_INFOTable) arcpy.Delete_management (L_COMMUNITY_INFOView, "") del L_COMMUNITY_INFOTable
# Delete Files Delete_Shapes = [] for shapefile in os.listdir(OUTPATH): if fnmatch.fnmatch(shapefile, '*.shp'): Delete_Shapes.append(shapefile) elif fnmatch.fnmatch(shapefile, '*.gdb'): Delete_Shapes.append(shapefile) else: pass del shapefile for shapefile in Delete_Shapes: get_file = os.path.join(OUTPATH, shapefile) arcpy.AddMessage("Deleting " + shapefile) arcpy.Delete_management(get_file)
Did anyone find a solution for how to delete locked shp files, I have same problem.. and very very frustrating...
It seems you are using the older/original search cursor instead of the newer data access (da) search cursor. Have you tried using the da.SearchCursor with a Python with statement? Does that change the result?
Did anyone get an answer to this. I am having the same issue however I am not using a search cursor at all I am using a delete feature.. it is deleting one feature (DB2) and then moving feature 1 DB1 to DB2 where the previous feature was deleted. I keep getting this error as well. it makes no sense.
To anyone looking for answer. Its a bug. See below
The arcpy.Delete_management (sde connection) function fails with the error, "000601: Cannot delete sde connection. May be locked by another application," in ArcMap 10.2.1.
N/A
Use os.remove() instead
NIM101220 - The arcpy.Delete_management (sde connection) funct..
This is True.
I had to delete the .gdb where it was happening and recreate it to be able to solve the issue!
No good. Any patch coming soon?
Thanks
Sugihono Budiman
Software Architect
• 917.873.5949
• sugihono.budiman@pcfcorp.com
Publishers Circulation Fulfillment, Inc.
www.pcfcorp.com