How To: Print the list of feature classes for an Enterprise geodatabase


Instructions provided describe how to print a list of feature classes for an Enterprise geodatabase.


Running the following Python script produces a list of all of the feature classes from the chosen Enterprise geodatabase.

The following script only prints feature classes in the geodatabase. Feature classes in a feature dataset are not printed.
  1. Open ArcMap.
  2. Click the Python window button.
[O-Image] PythonWindow2
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
  1. Edit the script below. Select either the name of the SDE connection file or the location of geodatabase connection. Use ## to comment out the section not used. There are two ways to input the database workspace into the Python script:
  • Provide the location of the database connection path for geodatabase. Copy the path from the ArcCatalog Window.
[O-Image] Location777
  • Provide the file name of the connection path of geodatabase. Right-click the selected data connection, click Properties and on the General tab, extract the path from the Name field. Copy the path from the ArcCatalog window.
[O-Image] DatabaseProperties
  1. Paste the path copied above into the Python script.
[O-Image] CopynPaste
  1. Paste the entire script above in the Python window in ArcMap and press Enter. The list of ArcSDE feature classes is displayed.
  2. To print the feature classes to a file, see code below:
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 (os.linesep)

#close text file

print "done"
To convert this script to a geoprocessing service, replace the environmental workspace parameter as follows:

env.Workspace = arcpy.GetParameterAsText(0)