How do I list the Schema name of an Element in an SDE database (Newbie Q)

1224
1
07-14-2013 02:59 PM
PeteSmyth
New Contributor
Hi All

I am new to all this, so thanks for your patience:D.

I used the code below to list the Name and data type of an element in an SDE database.

What I really need to do now is identify and write the Schema(element owner) for each element as well, as I have a number of Schemas in the Database.



import arcpy

# Create a Describe object
#
desc = arcpy.Describe(r"Database Connections\SDCM_SIS in PRD as 044231 DC.sde")

# Print some Describe Object properties
#

for child in desc.children:
    print "\t%s,%s" % (child.name,child.dataType)
Tags (2)
0 Kudos
1 Reply
ArkadiuszMatoszka
Occasional Contributor II
Hi,
I think you should already have schema name in child.name string.
Your child name should be something like:

SHEMA.FEATURE_CLASS_NAME



So all you need to do is split child.name on dot and get first element of the list.
import arcpy

# Create a Describe object
#
desc = arcpy.Describe(r"Database Connections\SDCM_SIS in PRD as 044231 DC.sde")

# Print some Describe Object properties
#

for child in desc.children:
    print "\tSchema: %s, Table: %s, DataType: %s " % (child.name.split('.')[0], child.name.split('.')[1], child.dataType)


Regards
Arek
0 Kudos