Created
May 23, 2012 22:28
-
-
Save BGranberg/2778230 to your computer and use it in GitHub Desktop.
Truncate and Load ArcSDE 10 Table.py - Copy and paste this script into notepad. Then set the sourceDataFullPath and updateDataFullPath variables appropriately and save the file. Schemas have to match exactly. Also, this script references an SDE connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcpy | |
arcpy.env.overwriteOutput = True | |
def fcUpdate(srcTable, tarTable): | |
tarTableView = arcpy.MakeTableView_management(tarTable,'targetTable') | |
srcTableView = arcpy.MakeTableView_management(srcTable,'sourceTable') | |
arcpy.DeleteRows_management(tarTableView) | |
arcpy.Append_management(srcTable, tarTable, 'TEST','#','#') | |
arcpy.Delete_management(tarTableView) | |
arcpy.Delete_management(srcTableView) | |
print "Success (" + srcTable + " uploaded)" | |
#Begin Main | |
sourceDataFullPath = r"C:\temp\yourgeodatabase.gdb\yourtablenameall" | |
updateDataFullPath = r"Database Connections\yourConnectionFileName\SDEDatabaseName.User.TableName" | |
if arcpy.GetCount_management(sourceDataFullPath) > 0: | |
fcUpdate(sourceDataFullPath, updateDataFullPath) | |
else: | |
print "No features found in " + srcTable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment