List Fields and Associated Domains--gets stuck on one table, why?
Hello! This script combs the SDE's feature classes and tables and reports back which fields have domains applied and which domains they are. It works beautifully, returning 553 records, until it hits a mystery table which our DBA created, called "DBASERVICE.TOAD_PLAN_TABLE." I don't know what causes the error (see below the script). I thought first that maybe the table had no fields, but SQLDev shows that it does--fields, but no data. I need either to fix the issue, or write error-handling that will skip this table so that it will move on with the rest of the items in the SDE. I don't know how to do either, so I'm hoping someone out there does! Thanks!
HERE'S THE SCRIPT:
import arcpy
#Set workspace environment to geodatabase
arcpy.env.workspace = r"Database Connections\PROD_fakesrv1.SDE.sde"
#Get list of feature classes in geodatabase
FCs = arcpy.ListFeatureClasses()
#Loop through feature classes in list
for FC in FCs:
#List fields in feature class
fields = arcpy.ListFields(FC)
#Loop through fields
for field in fields:
#Check if field has domain
if field.domain != "":
#Print feature class, field, domain name
print FC, ",", field.name, ",", field.domain
#Get list of tables in geodatabase
TBs = arcpy.ListTables()
#Loop through tables in list
for TB in TBs:
#List tables in feature dataset
fields = arcpy.ListFields(TB)
#Loop through fields
for field in fields:
#Check if field has domain
if field.domain != "":
#Print table, field, domain name
print TB, ",", field.name, ",", field.domain
HERE'S THE ERROR:
Traceback (most recent call last):
File "U:\SDE_Domains\WhichDomainsAreInUseHereSDE.py", line 30, in <module>
fields = arcpy.ListFields(TB)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 787, in ListFields
return gp.listFields(*args)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 342, in listFields
self._gp.ListFields(*gp_fixargs(args)))
IOError: DBASERVICE.TOAD_PLAN_TABLE
>>>