3

I am trying to delete a geodatabase using arcpy but I don't know how to do it. I have tried with 'Delete_management' but it doesn't work. Any ideas?

path = D:\ArcGIS_Pro_Projects\KML files\geodatabase_name.gdb
arcpy.Delete_management(path)
1
  • 3
    I have tried with 'Delete_management' but it doesn't work <-- Show us what you tried and the result that was returned or the error that was raised.
    – Paul H
    Oct 31, 2017 at 16:45

1 Answer 1

4

the path variable should be a string. put it in quotes like this:

path = 'D:\\ArcGIS_Pro_Projects\\KML files\\geodatabase_name.gdb'
arcpy.Delete_management(path)
4
  • 4
    It also either needs to have all forward slashes, or you can put an r in front. Such as path = r 'D:\ArcGIS_Pro_Projects\KML files\geodatabase_name.gdb'
    – saoirse
    Oct 31, 2017 at 17:53
  • 1
    It kind of works now. It does delete the geodatabase from my folder, but it doesn't remove it from the ArcGIS Pro catalog. It still appears on the Databases drop down menu (which doesn't make much sense since it doesn't exist anymore). Nov 1, 2017 at 9:50
  • That is a pointer to the database. The delete command does not tell ArcGIS Pro project to remove the reference.
    – KHibma
    Nov 1, 2017 at 14:06
  • Refresh the catalog. desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/…
    – mikewatt
    Jan 9, 2019 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.