I want to automate the truncate & loading of data between 2 enterprise geodatabases using python.
There are 6 features which are mixture of polygon & point features.
Has anyone got any idea how to code this simply?
Please clarify whether you mean "6 features" or 6 feature classes. A geodatabase (either file or enterprise) can hold multiple feature classes. A feature class can have multiple features. To use a file system analogy, a directory/folder (geodatabase) can hold many text files (feature classes). A text file can store many lines of text (features).
Truncate means to remove all features from a feature class, the feature class is not removed. The code I provided does that for the 6 specified feature classes.
Do you actually mean you have 6 features you need to delete from a single feature class in one gdb and then replace those features with 6 features selected from another feature class in a different gdb?
If so, truncate is definitely not what you want. You need to select the features you want to delete (e.g. select by attribute/location tools or make feature layer tool with a where clause) in your script and then run delete features tool.
Hi,
It's not all of the features from the geodb just 6 of them & they're enterprise db's so I have connection files for each geodb. How would I specify those in the script above? Also I need to be sure I only truncate/amend the 6 features & not the other features within the geodb
Assuming two separate geodatabases with all feature classes having the same name and schema:
feature_classes = ["fc1", "fc2", "fc3", "etc..."] for feature_class in feature_classes: arcpy.management.TruncateTable(f"dir:/path/to/connection1.sde/schema.{feature_class}") arcpy.management.Append([f"dir:/path/to/connection2.sde/schema.{feature_class}"], f"dir:/path/to/connection1.sde/schema.{feature_class}", "TEST")
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.