SDE feature class attributes updated with Python script not displaying

361
8
Jump to solution
07-26-2018 12:37 PM
LeeBrannon1
New Contributor III

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
LeeBrannon1
New Contributor III

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

8 Replies
DanPatterson_Retired
MVP Esteemed Contributor

are you using the Editor within arcpy?

Editor—Data Access module | ArcGIS Desktop 

Reply
0 Kudos
LeeBrannon1
New Contributor III

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.

Reply
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....

Reply
0 Kudos
LeeBrannon1
New Contributor III

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

Reply
0 Kudos
DrewFlater
Esri Contributor

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

Reply
0 Kudos
LeeBrannon1
New Contributor III

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.

Reply
0 Kudos
LeeBrannon1
New Contributor III

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.

Reply
0 Kudos
LeeBrannon1
New Contributor III

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