arcpy.Describe(relationshipclass) doesn't include key fields.

2529
10
05-19-2011 09:38 PM
MichaelAdornetto
New Contributor
I'm attempting to write a script to read the relationship classes from one geodatabase to another.  These tables have identical feature and object classes.

I should be able to select the relationshipclass in the source, use arcpy.Describe on them and get the parameter I'll need to perform an arcpy.createRelationshipClass_management.  Except the describe does not give me any access Primary / Foreign key information according to the documentation.  Is there away to get these field names because without it I can't recreate the relationship class.
Tags (2)
0 Kudos
10 Replies
HenryColomb
New Contributor II
Hello Michael
   I am working on the same thing and encountered the same problem. If you figure it out please post your solution as will I. This is not the first time Ive started out with python for a task and had to go back to ArcObjects.
Henry
0 Kudos
JohnGravois
Frequent Contributor
Currently Python does not have access to the following relationship class properties

OriginPrimaryKey
OriginForeignKey
DestinationPrimaryKey
DestinationForeignKey

The tracking number of this enhancement is [NIM048192 access to relationship class key properties in Python].  The status of the enhancement is currently "deferred", which means our development team will reconsider implementing it in our next major release.  Please contact Esri Technical Support for more information or to add your name to the list of customers requesting this functionality.
0 Kudos
JeffButurff
New Contributor
I know this is an old thread, but can anyone provide an updated status on this "enhancement"?  NIM048192

I'm trying to write a python script that copies feature classes and relationships across from one GDB to another.  But without access to the KEY fields on the relationship, I can't recreate the relates...
0 Kudos
brettangel
Occasional Contributor II
Did anybody ever find a solution to this?
0 Kudos
JeffButurff
New Contributor
Nope, never found a solution.  As far as I know, it's still an "enhancement request". 

Haven't tested at 10.2, so I don't know if it's been fixed there.
0 Kudos
NeilAyres
MVP Alum
Doesn't this give you the functionality you are looking for...
arcpy describe relationshipclass properties
http://resources.arcgis.com/en/help/main/10.2/#/RelationshipClass_properties/018v0000002n000000/
Cheers,
N
0 Kudos
JeffButurff
New Contributor
GSCUser85, thanks for the response.  However, if you look closely at the docs, you'll notice the most important piece of a relationship class is missing:  the key fields.  We need the key fields for both primary and foreign keys.
0 Kudos
JamesCrandall
MVP Frequent Contributor
I know this is an old thread, but can anyone provide an updated status on this "enhancement"?  NIM048192

I'm trying to write a python script that copies feature classes and relationships across from one GDB to another.  But without access to the KEY fields on the relationship, I can't recreate the relates...


Have you reviewed any of these?

http://forums.arcgis.com/threads/64318-Detect-Relationship-in-Feature-Class-or-Table
http://gis.stackexchange.com/questions/50846/copy-two-datasets-that-particpate-in-the-same-relations...
http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000015s000000
0 Kudos
JillianPenney
Esri Contributor
At 10.2.1 release, it will be possible to obtain the origin and destination class keys via python using the Describe function.

You can use:
arcpy.Describe(<relationshipclass>).OriginClassKeys  or
arcpy.Describe(<relationshipclass>).DestinationClassKeys


The result returned will look something like this:
[(u'OBJECTID', u'OriginPrimary', u''), (u'ParcelID', u'OriginForeign', u'')]
[(u'id', u'DestinationPrimary', u''), (u'RenterID', u'DestinationForeign', u'')]


Hope this helps!
0 Kudos