ArcGIS Pro 2.2.3.

I have a file geodatabase called "supportSource.gdb" with 3 tables, 2 feature classes and 3 relationship classes. I just want to copy the contents of this file geodatabase to another file geodatabase using python. Fairly straightforward, or so I thought.





Relationship Classes


enter image description here

If I try selecting all the tables and copying from the source geodatabase to a new empty geodatabase (called "dest.gdb" in Catalog, I get the following error:

enter image description here

Next, I tried a simple python script to copy the tables only into the destination geodatabase.

import os
from arcpy import env
destgdb = "E:\\Temp\\dest.gdb"
sourcegdb = "E:\\Temp\\supportSource.gdb"
env.workspace = sourcegdb
tableList = arcpy.ListTables()
for table in tableList:
    arcpy.Copy_management(table, os.path.join(destgdb, table))

Not only does this copy the tables, it also copies the feature classes as well as the relationship classes. This is not a problem for me because I need to copy all contents, not just tables. However, what does occur is a duplication of one of the tables, one of the feature classes, and one of the relationship classes. It also renames one of the relationship classes weirdly ("EnvtblTreeMaintenanceRecords__ATTACH__ATTACHREL" instead of "EnvtblTreeMaintenanceRecords__ATTACHREL")

enter image description here

My guess is that one of the tables, EnvtblTreeMaintenance participates in two relationship classes. It is the Destination for the TreeMaintenance relationship class and the Origin for the EnvtblTreeMaintenanceRecords__ATTACHREL relationship class.

This behaviour is not seen in ArcGIS Desktop 10.6.1. When I copy the three tables manually in Catalog in Desktop, they copy across without problems. All feature classes and relationship classes also copy along with the tables. However, when I use the above python code in Desktop, everything seems to copy correctly, but I get the following error in the python console:

Runtime error Traceback (most recent call last): File "", line 2, in File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 4314, in Copy raise e ExecuteError: ERROR 000725: Output Data Element: Dataset E:\Temp\dest.gdb\EnvtblTreeMaintenanceRecords__ATTACH already exists.

My question: what is the best way to copy the data in the source geodatabase to the destination database in ArcGIS Pro without duplication of tables, feature classes and relationship classes?

  • Copy entire database, delete what you don't need. – FelixIP Dec 21 '18 at 2:41
  • The example I gave is not actually my ultimate workflow. In the end, I need to migrate multiple SDE databases into a single database with different database schemas for each original database. – Fezter Dec 21 '18 at 2:44
  • Did you try using the associated_data parameter for the related tables and relationship classes? – Kirk Kuykendall Dec 21 '18 at 3:37
  • @KirkKuykendall no I didn't. How would you suggest I use it for my purposes? I can't see how it will help. I won't know the names of the feature classes or tables in the final dataset. There are thousands of them. – Fezter Dec 21 '18 at 3:57
  • 1
    Unfortunately, I'm working with a different client now and don't have access to the code anymore. However, from memory, I copied just the feature classes across which brought any related tables. Then, I copied any tables which didn't get copied across. Hope that helps. – Fezter Oct 2 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.