Howdy! My colleagues and I are having some difficulty trying to run the ListFields function against a feature dataset in an enterprise geodatabase that contains relationship classes. We are simply trying to export a list of all feature classes and their respective fields within every single feature dataset in a particular database. But it errors out on exclusively when ran against a feature dataset that contain relationship classes; if we run this against a feature dataset without any relationship classes, the code runs just fine. Below is the code we have:
import arcpy
import os
geodatabase_path = r"C:\PathTo\Database Connection.sde"
output_file_path = r"C:\Temp\Output.txt"
with open(output_file_path, "w") as f:
arcpy.env.workspace = geodatabase_path
datasets = arcpy.ListDatasets("*BadFeatureDataset*", "FeatureDataset")
f.write(f"Feature Dataset: {datasets}\n")
for ds in datasets:
for fc_fd in arcpy.ListFeatureClasses(feature_type='Polygon', feature_dataset=ds):
print (fc_fd)
f.write(f"Feature Class: {fc_fd}\n")
fields_fc_fd = arcpy.ListFields(fc_fd)
for field in fields_fc_fd:
f.write(f"{field.name}, {field.type}\n")
f.write("\n")
Traceback (most recent call last):
File "<string>", line 33, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 1214, in ListFields
return gp.listFields(dataset, wild_card, field_type)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 362, in listFields
self._gp.ListFields(*gp_fixargs(args, True)))
RuntimeError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
DBMS table not found [42S02:[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'gisdata.OWNER.FeatureClassName'.] [gisdata.OWNER.FeatureClassName][STATE_ID = 108472]
Note that this is just sampling of the error; the full error lists all of the 20+ relationship class DBMS tables it cannot find (even though they exist and, from what I understand, the code is not even searching against). Plus, in our effort to troubleshoot, we simplified the code a bit to only run against the problematic feature dataset.
I'm wondering if it's a glitch we've stumbled upon. For reference we are running this on a machine with ArcGIS Pro 3.2.0 installed and have tested this with the Python Window and Notebook.