I'm having a great deal of difficulty overwriting files when using ArcSDE. The usual 'arcpy.env.overwriteOutput' method doesn't seem to work.
When I run this script:
import arcpy
from arcpy import env
env.workspace = "L:\\DRAINAGE\\D_GROUP6\\STAFF\\CJE\\EDRN_3.sde"
arcpy.env.overwriteOutput = True
selected_link = "L:\\DRAINAGE\\D_GROUP6\\STAFF\\CJE\\EDRN_3.sde\\VALLAHC.EDRN_LINK6"
q_fid = 39
edrn_node = "L:\\DRAINAGE\\D_GROUP6\\STAFF\\CJE\\EDRN_3.sde\\VALLAHC.EDRN_NODE6"
join1 = "L:\\DRAINAGE\\D_GROUP6\\STAFF\\CJE\\EDRN_3.sde\\VALLAHC.join39"
arcpy.MakeFeatureLayer_management(selected_link, "feature_layer10")
arcpy.SelectLayerByAttribute_management("feature_layer10", "NEW_SELECTION", '\"OBJECTID_1\" = {0}'.format(q_fid))
arcpy.SpatialJoin_analysis("feature_layer10", edrn_node, join1, "JOIN_ONE_TO_MANY", "#", "#", "CONTAINS")
I get the following error:
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000601: Cannot delete L:\DRAINAGE\D_GROUP6\STAFF\CJE\EDRN_3.sde\VALLAHC.join39. May be locked by another application. Failed to execute (SpatialJoin).
I have attempted to get around this in a number of ways:
versioning/not versioning the data.
Checking/unchecking the overwrite geoprocessing operations box in geoprocessing options.
Using 'arcpy.Delete_management()' to delete the join at the end of the script. But ArcSDE won't let me and outputs the same 000601 error.
Does anybody have any ideas on how to get around this?
My script works fine when I use shapefiles or a regular geodatabase. I'm thinking there must be something I've missed related to ArcSDE that I'm not aware of as I don't have much experience with databases.