My goal is to copy all the feature classes in a file geodatabase into an sde geodatabase, skipping those elements which already exist in the output sde gdb. Both geodatabases have the same feature dataset structure and the sde geodatabase may have empty feature datasets.
To copy feature classes into feature datasets I need the full path of the output feature dataset where I want to copy each. For example, for UrbanData feature dataset it would be sqldb.DBO.UrbanData. To get that information I use this piece of code:
#input parameters
from_bd = r"C:\GISData\Buildings.gdb" #file gdb
to_bd =r"Database Connections\city_dat.sde" #sde connection file
arcpy.env.workspace = from_bd
sdebd = to_bd
datasetList = arcpy.ListDatasets()
desc = arcpy.Describe(sdebd)
for dataset in datasetList:
for child in desc.children:
if child.dataType == "FeatureDataset" and child.name == dataset:
fdset =child.name #the feature dataset full path
And I use it to copy each feature class to the output sde gdb:
for fc in arcpy.ListFeatureClasses('','',dataset):
if arcpy.Exists(sdebd + os.sep + fc)==False:
arcpy.Copy_management(fc, sdebd + os.sep + fdset + os.sep + new_fc)
To my surprise the Children property from arcpy.Describe object won't return empty feature datasets.
There's no mention of this behaviour in the Describe Object documentation.
So I need a workaround and I'm a bit stuck. Any ideas?