delete relationship class

1717
3
Jump to solution
11-10-2016 08:00 AM
jaykapalczynski
Frequent Contributor

How do I delete a relationship class in python

1 Solution

Accepted Solutions
Asrujit_SenGupta
MVP Regular Contributor

What about something simple like this:

import arcpy

# Local variables:
data_to_delete = "C:\\a.gdb\\t3meta"
Delete_succeeded = "false"

# Process: Delete
arcpy.Delete_management(data_to_delete, "RelationshipClass")

View solution in original post

3 Replies
jaykapalczynski
Frequent Contributor

I can create one like this but how do I delete one.

import arcpy
from arcpy import env

env.workspace = "C:\a.gdb"

origin_table = "Trail_meta"
destination_table = "trails_mfg"
out_relationship_class = "t3meta"
relationship_type = "SIMPLE"
forward_label = "Attributes from meta"
backward_label = "Attributes from trail"
message_direction = "NONE"
cardinality = "ONE_TO_MANY"
attributed = "NONE"
origin_primary_key = "OBJECTID"
origin_foreign_key = "TRAIL_NAME"

arcpy.CreateRelationshipClass_management(origin_table,
                                         destination_table,
                                         out_relationship_class,
                                         forward_label,
                                         backward_label,
                                         message_direction,
                                         cardinality,
                                         attributed,
                                         origin_primary_key,
                                         origin_foreign_key)
0 Kudos
BrittneyWhite1
Esri Contributor

You should be able to use Delete—Help | ArcGIS for Desktop. The documentation specifically mentions relationship classes: "Deleting a relationship class deletes the row corresponding to that relationship from the relationship table."

Asrujit_SenGupta
MVP Regular Contributor

What about something simple like this:

import arcpy

# Local variables:
data_to_delete = "C:\\a.gdb\\t3meta"
Delete_succeeded = "false"

# Process: Delete
arcpy.Delete_management(data_to_delete, "RelationshipClass")