kyanuk1

Rename_management / ListFeatureClasses in SDE database

Discussion created by kyanuk1 on May 22, 2012
Latest reply on May 22, 2012 by kyanuk1
Hello,

I am working on running through an SDE database, and renaming a few hundred point feature classes using arcpy.Rename_management().  I use ListFeatureClasses to find the files, and once I hit the ones I want to rename, I use a searchcursor to use a field to rename.

When I get to the part in my script where I use this, the script seems to freeze, and I was wondering if SDE feature classes support this?  I ran it on a file gdb, and everything worked fine ...

import arcpy
from arcpy import env

def updateName():
    arcpy.env.workspace = raw_input("Enter path of database: ")
    for tab in arcpy.ListFeatureClasses("","Point",""):
        desc = arcpy.Describe(tab)
        newName = ""

        if desc.datasetType == 'RasterDataset':
            print "Skipping raster "+tab

        if desc.datasetType == 'FeatureClass':
            print "Searching "+desc.datasetType+": "+tab

            for row in arcpy.SearchCursor(tab):
                newName = "StandID_"+str(row.StandID)+"_Pt"
                print "    Updating "+tab+" to "+newName+"..."

                arcpy.Rename_management(tab, newName)
                break

updateName()
print "\nUpdate complete for "+arcpy.env.workspace+"."

Outcomes