Hi,
I have a feature class called DeviceView that I need to delete and recreate. The logic that I use to delete feature classes is:
def delete(fc):
if arcpy.Exists(fc):
print(f"{fc} exists, deleting...", end="")
try:
arcpy.Delete_management(fc)
print("successful")
except Exception as e:
print(f"unable to delete, reason: {e}")
else:
print(f"{fc} doesn't exist, skipping...")
When I execute the logic above, I get the following log in the console:
DeviceView exists, deleting...successful
Which indicates to me that the operation was 'successful' and no exception was generated while attempting to delete it.
However, the View still exists in the database after executing that logic and a subsequent scripts fails because of this.
I know the delete logic works for other feature classes (not views) which are effectively deleted from the DB.
Thanks in advance for any advise that could give an insight into this issue.
Delete (Data Management)—ArcGIS Pro | Documentation
It works on objects on disk or those created in the memory workspace (not just in memory)
Write geoprocessing output to memory—ArcGIS Pro | Documentation
otherwise it has no effect
Thanks Dan, I will have a look at this.
Thanks again @DanPatterson . After a second look, the reason of this issue turned out to be a rather silly one. In ArcGIS Server Manager, we have these two map services: Device and DeviceView. The second one is pointing to the DB View I'm mentioning in the description of this post.
I hadn't stopped that service. Once I did that, the script deleted the view from the DB.
Apologies for the rookie mistake