SDE feature class attributes updated with Python script not displaying

2047
10
Jump to solution
07-26-2018 12:37 PM
LeeBrannon1
Occasional Contributor

My Python script tool runs from the geoprocessing pane in ArcGIS Pro 2.2, and what it does is create a new point in an SDE feature class and populate  attributes.  You could say that it is working, but the problem is that the new attributes for the point do not display in the attribute table until I perform more editing (manual, not via the script) on that feature class.  The new attributes need to be seen immediately after the script ends.  

I use an edit session in arcpy (my SDE feature class is versioned) and within that I do an update cursor for the new attributes.  But somehow there seems to be a delay with edits being committed or the row getting updated or the edit session being saved.

0 Kudos
1 Solution

Accepted Solutions
LeeBrannon1
Occasional Contributor

I got it working!  

The feature layer idea wasn't it at all...still using the feature layer, but what did work was actually very simple.  At the very end of my script, which is immediately after the StopEditing(True) statement, I added a Try/Except statement - where I added code to change the SDE database connection back to the Default version - since I was finished editing anyway.   Maybe it just needed some code at the end to help the edit session complete and the SDE database to refresh, and the specific code I gave it really didn't matter what that was.  I'm not sure.

View solution in original post

10 Replies
DanPatterson_Retired
MVP Emeritus

are you using the Editor within arcpy?

Editor—Data Access module | ArcGIS Desktop 

0 Kudos
LeeBrannon1
Occasional Contributor

Dan,

Yes, I am using arcpy.da.Editor and arcpy.da.UpdateCursor.  And earlier in the code I use arcpy.ChangeVersion_management to set the specific version of the data that I am editing, and I also called arcpy.CreateDatabaseConnection_management to set a connection specifically for that version.

0 Kudos
ThomasColson
MVP Frequent Contributor

I had a sort of similar case where the solution was to "Disable Caching" on the layer in question: Right Click layer in TOC, Properties, Cache....

0 Kudos
LeeBrannon1
Occasional Contributor

Thanks Thomas, good suggestion, I tried it but it didn't change anything.

0 Kudos
by Anonymous User
Not applicable

@LeeBrannon1  Hi Brannon, 

I am building a script tool using changeversion, have you ever try to create a dropdown list of all the versions in a default.sde? 

0 Kudos
LeeBrannon1
Occasional Contributor

No, I have not tried to create a dropdown list of sde versions.  My experience with changeversion is limited to just the script tool that was the subject of this post.  

0 Kudos
DrewFlater
Esri Regular Contributor

Does your script tool have a normal output parameter, or use a derived output parameter?

0 Kudos
LeeBrannon1
Occasional Contributor

No output parameter that I am aware of, although I'm a little confused by the question.  The script tool updates data and then ends, no further processing.

0 Kudos
LeeBrannon1
Occasional Contributor

Could this problem be related to my using a feature layer as the input to the Update Cursor (within the edit session)?  Would it behave better if I used the original SDE feature class instead? 

The reason that I use a feature layer instead of the actual feature class is because I had to change the version of the database, and that tool required a feature layer.

0 Kudos