[GIS] Copying ArcSDE datasets and features in Python give ERROR 000732

arcgis-10.1arcpyenterprise-geodatabaseerror-000732

I keep getting a kick back that says this:

ERROR 000732: Input Features: Dataset 'Database
Connections\Wyoming.sde\Supporting_MT_DBO_Geology' does not exist or
is not supported Failed to execute (FeatureClassToGeodatabase).

# Import modules
import sys, string, os, datetime, arcpy

# Sets the start time
nowstart = datetime.datetime.now()

# Set location of SDE instance - in this case a special SDE connection just for this script
SDEname = r"C:\Users\user\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Wyoming.sde"
SDEnameShort = r"'Database Connections\Wyoming.sde"


# Set up the log file
LogLoc = r"P:\Database_Backups\SDE\BackupLog_"
LgFile = LogLoc + nowstart.strftime("%Y_%m_%d_%H%M") + ".log"
logfile_out = open(LgFile, 'w')
# Write the start time to the log file
logfile_out.write("Backup process started on " + nowstart.strftime("%Y_%m_%d %H:%M") + "\n")

# Deletes temp timestamp
del nowstart

# Add the Conversion and Data Management Toolboxes to the geoprocessor


#Sets work environment to SDEname
arcpy.env.workspace = SDEname

#Sets environment to overwrite
arcpy.env.overwriteOutput = True

# Resets the start time
nowstart = datetime.datetime.now()

# Creates a variable for naming the backup GDB
YearMonthDayTime = nowstart.strftime("%Y_%m_%d_%H%M")

# Variables and parameters for setting up the backup GDB
outgdb = "PetroPAM_Backup_" + YearMonthDayTime + ".gdb"
outpath = r"P:\Database_Backups"
output = outpath + os.sep + outgdb
print output


#Create the backup GDB
arcpy.CreateFileGDB_management(outpath, outgdb)
print "Created BackupGDB"




# Find and export feature classes in datasets to a backup GDB
logfile_out.write("\nCreating Feature Dataset List...\n")
fc = arcpy.ListFeatureClasses()

dsList = arcpy.ListDatasets("*", "Feature")
print dsList
print "The Datasets"
for dsGEO in dsList:
    outDS = arcpy.ValidateTableName(dsGEO)
    arcpy.CreateFeatureDataset_management(output, outDS)
    fcListGEO = arcpy.ListFeatureClasses("*","",dsGEO)
    print fcListGEO
    print "Feature Classes in Dataset"
    for fcGEO in fcListGEO:
        print fcGEO
        print SDEnameShort + os.sep + outDS + os.sep + fcGEO
        arcpy.FeatureClassToGeodatabase_conversion(SDEnameShort + os.sep + outDS + os.sep + fcGEO, output + outDS)

Any ideas? I'm using ArcMap 10.1

Best Answer

The errors you are encountering are a direct result of not inputting the correct number of parameters into the tool you are calling. Create Feature Dataset requires both out_dataset_path and out_name.

In addition to this there are some other issues with your code.

The help documentation for the Feature Class to Geodatabase tool states:

The inputs can include shapefiles, coverage feature classes, VPF feature classes, or geodatabase feature classes

You are attempting to input a feature dataset. Since you're choosing to loop through your feature classes I would think the input to this process would be a feature class.

Try this modified version of your code where a feature class in used in place of the feature dataset.

    dsList = arcpy.ListDatasets()
    print dsList
    for dsGEO in dsList:
        arcpy.CreateFeatureDataset_management(dsGEO, **out_name**)
        fcListGEO = arcpy.ListFeatureClasses(dsGEO)
        for fcGEO in fcListGEO:
            arcpy.FeatureClassToGeodatabase_conversion(fcGeo, **output_geodatabase**)

Pending the rest of your code is correct this will loop through each feature class inside of each feature dataset and add it to your geodatabase.