Hello all,
We are migrating from arcgis 10.1 to 10.5. And I am writing a script that copies the featureclasses and tables etc to the new database server containing an arcgis 10.5 geodatabase.
Here is my workflow for this:
Am I missing something?
Hi Ruud,
I've run into issues trying to use the Copy_management tool to migrate data. For example, I was helping a customer yesterday trying to perform the same scenario and one of their feature datasets had a relationship class to another feature dataset. The Copy tool will copy related data, so a portion of the feature dataset was copied since it contained some related feature classes. When the script iterated through to this feature dataset, it would get skipped because it already existed in the new geodatabase, however not all of the feature classes were copied.
I find it best to perform the copy/paste directly in the Catalog window by selecting all the feature classes/datasets and tables > Copy > right-click on the new geodatabase > Paste. Afterwards, you can always run a script to make sure the counts are the same. Ex:
import arcpy
oldGDB = r"Database Connections\oldGDB.sde"
newGDB = r"Database Connections\newGDB.sde"
def getCount(workspace):
arcpy.env.workspace = workspace
count = 0
for dataset in arcpy.ListDatasets("*"):
for fc in arcpy.ListFeatureClasses("*", "", dataset):
result = arcpy.GetCount_management(fc)
count += int(result.getOutput(0))
for fc in arcpy.ListFeatureClasses("*"):
result = arcpy.GetCount_management(fc)
count += int(result.getOutput(0))
for table in arcpy.ListTables("*"):
result = arcpy.GetCount_management(table)
count += int(result.getOutput(0))
return count
oldGDBCount = getCount(oldGDB)
newGDBCount = getCount(newGDB)
print("Old GDB Count: " + str(oldGDBCount))
print("New GDB Count: " + str(newGDBCount))
If you are copying simple features and tables, have you tried the Copy Features and Copy Rows tools? They may behave better since the geodatabase format has changed enough over four versions that the workspace structure may be buggy when using Copy. If there are relationships etc, you could rebuild them in the new format.
Thanks for the replies all.
I think the problem is something in one of my settings because when I do the following simple arcpy command in python:
import arcpy
arcpy.env.workspace = "Database Connections\\xyz_select@geooraint.sde"
featureclasses = arcpy.ListFeatureClasses()
print (str(len(featureclasses)))
It gives me 0 results. This is straight from python. So arcpy from python seems to think there are no feature classes in the old geodatabase.
When I run the exact same command from the python window in arcmap i get something like 1600 results, which should be correct.
Both python versions give the same version number (2.7.12).
Does anyone have an idea of a setting that I need to change?