Copying featureclass, in arcpy, from 10.1 geodatabase to 10.5 geodatabase not working

06-08-2017 05:51 AM
New Contributor

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:

  1.  I start with making a basic model which only contains the copy (data management tool) and see if that works.
    1. It did work, so the featureclass is copied from the old 10.1 geodatabase to the new 10.5 geodatabase.
  2. I exported the tool to a python script and coded some logging around it.
    1. When I run the script it says that the feature class does not excist or is not supported.
    2. I then tried to run the original exported tool and I get the same error messag
      1. This should be exactly the same as running the tool from model builder or the tool box

Am I missing something?

0 Kudos
3 Replies
Esri Esteemed Contributor

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))
MVP Esteemed Contributor

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.

0 Kudos
New Contributor

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?

0 Kudos