Rename_management / ListFeatureClasses in SDE database

248
2
05-22-2012 06:13 AM
KevinYanuk
Occasional Contributor
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+"."
Tags (2)
0 Kudos
2 Replies
BruceNielsen
Occasional Contributor III
If all you're doing is renaming the point featureclasses, you don't need a searchcursor. What is your criteria for determining the new name?
0 Kudos
KevinYanuk
Occasional Contributor
If all you're doing is renaming the point featureclasses, you don't need a searchcursor. What is your criteria for determining the new name?


Well, the new name is coming from a field within the Feature Class called "StandID" - So, I wouldn't I need one to access that field?

Hence:

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



It works fine with the test geodatabases I was using, it just hangs up at the Rename_management() when I use it on the SDE.
0 Kudos