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.
EnvGENvecAuditStreetSweeping__ATTACH EnvtblTreeMaintenanceRecords EnvtblTreeMaintenanceRecords__ATTACH
EnvGENvecAuditStreetSweeping__ATTACHREL EnvtblTreeMaintenanceRecords__ATTACHREL TreeMaintenance
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:
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")
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?