>>> desc = arcpy.Describe(r'Database Connections\BWQP_NDEP24.sde\BWQP.AssessedStreams2010')
>>> desc
<geoprocessing describe data object object at 0x1E829440>
>>> print "%-22s %s" % ("RelationshipClassNames:", desc.relationshipClassNames)
RelationshipClassNames: []>>> rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"] >>> rc_list [u'BWQP.Lakes_to_TMDL', u'BWQP.Lakes_to_Waterbody', u'BWQP.Rivers_to_TMDL', u'BWQP.Rivers_to_Waterbody', u'BWQP.AssessedLakes_to_IR10', u'BWQP.AssessedStreams_to_IR10']
import arcpy from arcpy import env workspace = env.workspace = r'your_workspace' def detectRelationship(): rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"] for rc in rc_list: rc_path = workspace + "\\" + rc des_rc = arcpy.Describe(rc_path) origin = des_rc.originClassNames destination = des_rc.destinationClassNames print "Relationship Class: %s \n Origin: %s \n Desintation: %s" %(rc, origin, destination) detectRelationship()
Relationship Class: NDEP.WaterDiv_to_Owners_NDWR2012 Origin: [u'NDEP.WaterDiversions_NDWR2012'] Desintation: [u'NDEP.WaterDiv_Owners_NDWR2012']
import arcgisscripting
gp = arcgisscripting.create(9.3)
SDE_WORKSPACE = "Database Connections\\sde931.sde"
FGDB_WORKSPACE = "c:/931t.gdb"
#CHECK IF EXISTS
def objExists(o):
 gp.workspace = FGDB_WORKSPACE
 if gp.Exists(o):
  print "  " + o + " exists"
  return True
 else:
  #print "  " + o + " does not exist"
  return False
# START COPY FEATURE CLASSES
gp.workspace = SDE_WORKSPACE
fcList = gp.ListFeatureClasses()
for sde_fc in fcList:
    #print "Start copy " + sde_fc
    if not objExists(sde_fc.split(".")[1]):
        gp.workspace = SDE_WORKSPACE
        gp.Copy_management(sde_fc, "C:\\931t.gdb\\" + sde_fc.split(".")[1])
    #print "End copy " + sde_fc
# START COPY TABLES
gp.workspace = SDE_WORKSPACE
tList = gp.ListTables()
for sde_t in tList:
    #print "Start copy " + sde_t
    if not objExists(sde_t.split(".")[1]):
        gp.workspace = SDE_WORKSPACE
        gp.Copy_management(sde_t, "C:\\931t.gdb\\" + sde_t.split(".")[1])
    #print "End copy " + sde_t
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		desc = arcpy.Describe("myTable")
print desc.relationshipClassNamesimport arcpy from arcpy import env workspace = env.workspace = r'your_workspace' def detectRelationship(): rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"] for rc in rc_list: rc_path = workspace + "\\" + rc des_rc = arcpy.Describe(rc_path) origin = des_rc.originClassNames destination = des_rc.destinationClassNames print "Relationship Class: %s \n Origin: %s \n Desintation: %s" %(rc, origin, destination) detectRelationship()
Here's some code I've been using. It might help.
def GetWorkspace(inputFeatureClass):
    """
    Returns the workspace which contains the input feature class
    """
    path = arcpy.Describe(inputFeatureClass).path
    if arcpy.Describe(path).dataType in ("Workspace", "Folder"):
        workspace = path
    else:
        workspace = arcpy.Describe(path).path
    return workspace
def hasRelatedTables(inputTable):
    """
    Returns true if the input table participates in a relationship class
    """
    if arcpy.Describe(inputTable).relationshipClassNames != []:
        return True
    else:
        return False
def GetRelatedTableInfo(inputTable):
    """
    Returns a dictionary of relationship class info
    """
    relTableInfo = {}
    workspace = GetWorkspace(inputTable)
    if hasRelatedTables(inputTable):
        relClasses = arcpy.Describe(inputTable).relationshipClassNames
        for rc in relClasses:
            relClassProps = arcpy.Describe(os.path.join(workspace, rc))
            if os.path.join(workspace, relClassProps.originClassNames[0]) == inputTable:
                isTopLevel = True
            else:
                isTopLevel = False
            relTableInfo[relClasses.index(rc)] = {"IsTopLevel": isTopLevel,
                                                  "RelClassName": rc,
                                                  "ParentTable": os.path.join(workspace, relClassProps.originClassNames[0]),
                                                  "ChildTable": os.path.join(workspace, relClassProps.destinationClassNames[0]),
                                                  "PrimaryKey": [k[0] for k in relClassProps.originClassKeys if k[1] == "OriginPrimary"][0],
                                                  "ForeignKey": [k[0] for k in relClassProps.originClassKeys if k[1] == "OriginForeign"][0],
                                                  "IsAttachment": relClassProps.isAttachmentRelationship,
                                                  "Cardinality": relClassProps.cardinality}
        return relTableInfo
    else:
        return {}
def ListRelatedTables(inputTable, excludeAttachments = False):
    """
    """
    if not hasRelatedTables(inputTable):
        return None
    
    relatedTables = []
    relTableInfo = GetRelatedTableInfo(inputTable)
    if excludeAttachments:
        for item in relTableInfo:
            if not relTableInfo[item]["IsAttachment"]:
                relatedTables.append(relTableInfo[item]["ParentTable"])
                relatedTables.append(relTableInfo[item]["ChildTable"])
    else:
        for item in relTableInfo:
            relatedTables.append(relTableInfo[item]["ParentTable"])
            relatedTables.append(relTableInfo[item]["ChildTable"])
    relatedTables = list(set(relatedTables))
    if inputTable in relatedTables:
        relatedTables.remove(inputTable)
    return relatedTables
For list related tables function I only wanted non-attachment relationships.
Hope this helps!
Micah