Solved! Go to Solution.
I GOT IT! Not sure why it took me so long or how picky python is, but this code worked:
import arcpy
from arcpy import env
env.workspace = r"database connections\connection to KM-BASE.sde"
arcpy.AddField_management("BASE.BASE.Exposures_Platte", "STATE", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
The issue was I needed to fully qualify the table name, even though I had to physically login to that database as the schema owner. I thought that login would have resolved the name schema, but I guess not.
I did have issues with a schema lock, although I was the only one logged in, but I just killed Catalog and reopened it, logged in as the schema owner, and copied the code in, and it worked! Thanks everyone for looking into this issue!
As a side issue to this situation, instead of adding new fields to an existing feature class within that feature dataset, now I am trying to copy that existing feature class and paste a new feature class (this one a linear feature instead of a point feature) into that same feature dataset, using this code:
import arcpy
from arcpy import env
env.workspace = r"database connections\connection to KM-BASE.sde"
#Use existing Span (point) feature (Exposures_Platte) as template to create new linear Span feature class
arcpy.CreateFeatureclass_management("database connections/connection to KM-BASE.sde", "BASE.BASE.KMC.Exposures_Platte_Line", "POLYLINE", "BASE.BASE.Exposures_Platte", "ENABLED", "ENABLED")
and ArcCatalog crashes after about a minute of thinking, no error thrown. Any ideas on this issue?
arcpy.CreateFeatureclass_management(Path, r"Exposures_Platte_Line_Test2", "POLYLINE", Path +"\BASE.BASE.Exposures_Platte")
You are correct, you should not need to change your workspace to the dataset. Are you sure that is the name of the feature class? SDE feature classes usually have the username appending to the beginning of the feature class EG SDE.FEATURECLASS.
... arcpy.env.workspace = r"Database Connections\<YOUR CONNECTION>.sde" fcList = arcpy.ListFeatureClasses("","","<Feature Dataset Name>") print len(fcList) ...
Hi Matt,
The ListFeatureClasses function allows for limiting the results by feature dataset.... arcpy.env.workspace = r"Database Connections\<YOUR CONNECTION>.sde" fcList = arcpy.ListFeatureClasses("","","<Feature Dataset Name>") print len(fcList) ...
This returned the number of feature classes in my feature dataset when I ran it. I used the fully qualified Feature Dataset Name as well.
Hope this helps.
John
Help Topic:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v0000001n000000
dsList = arcpy.ListDatasets("TFM.TFM_*", "Feature") for ds in dsList: fcList = arcpy.ListFeatureClasses("","",ds) ds = str(ds).partition(".")[2] print "Starting "+ds arcpy.CreateFeatureDataset_management(output, ds, sr) for feature in fcList: featout = str(feature).partition(".")[2] try: if not arcpy.Exists(output+ds+"\\"+featout): arcpy.FeatureClassToFeatureClass_conversion(feature, output+ds, featout)
Kind of messy, but here is how I have accessed SDE feature classes in a dataset before. It is exporting all the feature class in each dataset in the target SDE.dsList = arcpy.ListDatasets("TFM.TFM_*", "Feature") for ds in dsList: fcList = arcpy.ListFeatureClasses("","",ds) ds = str(ds).partition(".")[2] print "Starting "+ds arcpy.CreateFeatureDataset_management(output, ds, sr) for feature in fcList: featout = str(feature).partition(".")[2] try: if not arcpy.Exists(output+ds+"\\"+featout): arcpy.FeatureClassToFeatureClass_conversion(feature, output+ds, featout)
I GOT IT! Not sure why it took me so long or how picky python is, but this code worked:
import arcpy
from arcpy import env
env.workspace = r"database connections\connection to KM-BASE.sde"
arcpy.AddField_management("BASE.BASE.Exposures_Platte", "STATE", "TEXT", "", "", "50", "", "NULLABLE", "NON_REQUIRED", "")
The issue was I needed to fully qualify the table name, even though I had to physically login to that database as the schema owner. I thought that login would have resolved the name schema, but I guess not.
I did have issues with a schema lock, although I was the only one logged in, but I just killed Catalog and reopened it, logged in as the schema owner, and copied the code in, and it worked! Thanks everyone for looking into this issue!
As a side issue to this situation, instead of adding new fields to an existing feature class within that feature dataset, now I am trying to copy that existing feature class and paste a new feature class (this one a linear feature instead of a point feature) into that same feature dataset, using this code:
import arcpy
from arcpy import env
env.workspace = r"database connections\connection to KM-BASE.sde"
#Use existing Span (point) feature (Exposures_Platte) as template to create new linear Span feature class
arcpy.CreateFeatureclass_management("database connections/connection to KM-BASE.sde", "BASE.BASE.KMC.Exposures_Platte_Line", "POLYLINE", "BASE.BASE.Exposures_Platte", "ENABLED", "ENABLED")
and ArcCatalog crashes after about a minute of thinking, no error thrown. Any ideas on this issue?
arcpy.CreateFeatureclass_management(Path, r"Exposures_Platte_Line_Test2", "POLYLINE", Path +"\BASE.BASE.Exposures_Platte")