gis_tech

Python script not disconnecting from Geodatabase after editing

Discussion created by gis_tech on Jul 23, 2012
Latest reply on Jul 23, 2012 by gis_tech
I've written a python script that reads an XML file and inserts the XML data into a file geodatabase. The script works great with the exception that it appears that the code does not detach from the FeatureClass. The symptom is as follows:

I create a duplicate of the feature class to test the code. I run the python code against the new test feature class and it run successfully. I go into ArcCatalog and attempt to delete the new test feature class by right-clicking on the object and choosing "Delete". I get the following error: "Failed to delete the selected object(s)".

I need help figuring out how to get my python script to let go of this feature class when it's done. All help is greatly appreciated.

Here's my code:

import arcpy, xml.etree.ElementTree as ET 

arcpy.DeleteRows_management("C:/Data/GISData/DBName.gdb/SitesTest6")

# Code for accessing the XML file
tree = ET.parse("XMLTest.xml")
root = tree.getroot()
iter = root.getiterator() 

# Create insert cursor for table
rows = arcpy.InsertCursor("C:/Data/GISData/DBName.gdb/SitesTest6")

# Create new rows. Set the initial row ID and distance values
for element in iter:
    row = rows.newRow()
    if element.tag == "SiteID":
        vSiteID = element.text
    if element.tag == "SiteName":
        vSiteName = element.text
    if element.tag == "Address1":
        vAddress1 = element.text
    if element.tag == "City":
        vCity = element.text
    if element.tag == "State":
        vState = element.text
    if element.tag == "ZIP":
        vZIP = element.text
    if element.tag == "ContactName":
        vContactName = element.text
    if element.tag == "ContactEmail":
        vContactEmail = element.text
    if element.tag == "ContactTitle":
        vContactTitle = element.text
    if element.tag == "SiteCategory":
        vSiteCategory = element.text
    if element.tag == "Latitude":
        vLatitude = element.text
    if element.tag == "Longitude":
        vLongitude = element.text
    if element.tag == "URL":
        vURL = element.text
    if element.tag == "Images":
        vImages = element.text
    if element.tag == "Documents":
        vDocuments = element.text
    if element.tag == "PolSitReps":
        vPolSitReps = element.text
    if element.tag == "Contacts":
        vContacts = element.text
    
    if element.tag == "Links":   # Last element in each dataset. Also, not needed
       row.SiteID = vSiteID
       row.SiteName = vSiteName
       row.SiteAddress1 = vAddress1
       row.SiteCity = vCity
       row.SiteState = vState
       row.SiteZIP = vZIP
       row.ContactName = vContactName
       row.ContactEmail = vContactEmail
       row.ContactTitle = vContactTitle
       row.SiteCategory = vSiteCategory
       row.Latitude = vLatitude
       row.Longitude = vLongitude
       row.SiteAbstractURI = vSiteAbstractURI
       rows.insertRow(row)


# Delete cursor and row objects to remove locks on the data 
del row 
del rows
del iter
del root
del tree

Outcomes