I would like to know if it's possible to use python to transfer features class from SDE into a GDB and then transfer it back to SDE without losing SDE parameters such topology, versionning, relationship.
The reason of this loop is that I would like to use FME to edit the features class, but I dont have the license to read/write into SDE directly so I would like to do the updates inside a GDB.
Can somebody tell if it's possible, and if yes, expose the arcpy functions that I shall use?
I have this so far
Before running the FME translation:
#import FeatureCLass from SDE into GDB used as input for FME
import arcpy
SOURCE = "C:/Users/DemMa18/AppData/Roaming/ESRI/Desktop10.3/ArcCatalog/GEOP011@demma18.sde/DEMMA18.TestFME"
DEST = "C:/temp/arcgis/FME/TestFME_IN.gdb"
#delete all FC in GDB
arcpy.env.workspace = DEST
fcDestList = arcpy.ListFeatureClasses()
for fc in fcDestList:
arcpy.Delete_management(fc)
#copy SDE FC into GDB
arcpy.env.workspace = SOURCE
fcSourceList = arcpy.ListFeatureClasses()
for fc in fcSourceList:
arcpy.Copy_management(fc, DEST+"/"+fc)
After FME translation:
#export FeatureCLass from GDB used as output by FME to SDE
import arcpy
DEST = "C:/Users/DemMa18/AppData/Roaming/ESRI/Desktop10.3/ArcCatalog/GEOP011@demma18.sde/DEMMA18.TestFME"
SOURCE = "C:/temp/arcgis/FME/TestFME_OUT.gdb"
#Delete features in SDE FC
arcpy.env.workspace = DEST
fcDestList = arcpy.ListFeatureClasses()
for fc in fcDestList:
arcpy.TruncateTable_management(fc)
#Append GDB FC into SDE FC
arcpy.env.workspace = SOURCE
fcSourceList = arcpy.ListFeatureClasses()
for fc in fcSourceList:
arcpy.Append_management(fc, DEST+"/"+fc)
Best Answer
I have slightly modified another script I had laying around which should do what you want, using Insert Cursors and Update Cursors. It does require you to specify the name of your unique ID field (can't be ObjectID). It also has no error checking (I didn't need it for what I was doing but as you're modifying SDE feature classes it may be wise to add some!)
Please back-up your data and test before using: