Is This Content Helpful?
We're glad to know this article was helpful.
Instructions provided describe how to print a list of feature classes for an ArcSDE geodatabase.
Running the following Python script produces a list of all of the feature classes from the chosen SDE geodatabase.
Code: import arcpy from arcpy import env import os # Establish connection for workspace env.workspace = r"Database Connections\Child Database" #call ListFeatureClass function fcList = arcpy.ListFeatureClasses() # Print the name of the current fc: for fc in fcList: print fc
Code: import arcpy from arcpy import env import os # Set the workspace for the ListFeatureClass function env.workspace = r"Database Connections\Child Database 1017857.sde" # Use the ListFeatureClasses function to return a list of all fc's in the sde gdb: fcList = arcpy.ListFeatureClasses() # Write the name of the current fc in text file: txtFile = open(r"C:\data\FeatureClassList.txt","w") for fc in fcList: print fc # Write messages to a Text File txtFile.write(fc) txtFile.write (os.linesep) #close text file txtFile.close() print "done"
Note: To convert this script to a geoprocessing service, replace the environmental workspace parameter as follows: env.Workspace = arcpy.GetParameterAsText(0)