Cannot get children of workspace if ws is SDE

1263
2
02-09-2017 01:04 PM
TamiOnstad
New Contributor III

I have this in Python:

workspace = r'Database Connections\XXX.sde'

rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"]

Which should give me all the relationship classes at the root of my SDE database, and I have many!  However, rc_list comes up empty every single time.  Works for a FGDB, does not work for SDE.  I have tossed every permutation of the SDE connection workspace path at this, and nothing works.  The other workspace properties like server, instance, connectionString all get returned every time, but the children are blank.

Am I missing something?  This is the only way I know to grab all the relationship classes at the root, so I am puzzled as to why it finds nothing.

Thanks

Tami

0 Kudos
2 Replies
TamiOnstad
New Contributor III

I figured this out, I had to be connected as the SDE user before the DESCRIBE would return any children at the root.  The user I connect as normally has privileges on everything and can see everything in ArcCatalog, and Describe as this user can see all the tables/fc/rel classes inside the datasets, but once you move out to the root level that same user gets no results back on a Describe of the workspace.  

Interesting, and nothing in any documentation about how you need to be connected to use the Describe for the workspace level when you want to see subelements.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I believe ArcPy Walk will work without having to be SDE user:

>>> sde_ws = # path to SDE connection file
>>> walk = arcpy.da.Walk(sde_ws, datatype="RelationshipClass")
>>> for root, dirs, files in walk:
...     for file in files:
...         print file
...     break  # break here ensures only root-level relationship classes are returned.
...            # remove break statement to return all relationship classes
>>>‍‍‍‍‍‍‍‍