0

I am writing a script to auto update attributes for several FCs in my enterprise SDE.

I am testing the script and there are no processing bugs however there is strange behavior. When the script completes both the default version and the child version have received the updates. There is no part of the script that reconciles or posts the version. Logically this should not be happening.

I have set the workspace to the specific version (not the default) by creating a new database connection with the version of interest defined as the the active version. As per this post.

I tried to use arcpy.ChangeVersions_management as an alternative but that only works in an active view inside ArcMap and does not work remotely. Error 00825.

My instinct is that there is some setting in the SDE that will prevent that I am not aware of. Is there any way to fix this?

I included the sections of code that I believe might be producing this behavior:

#Set workspace (as per above)
thefolder = os.path.dirname(sys.argv[0])    # folder path containing script
Environ = thefolder + "\\Connections\\DevVersion.sde"
arcpy.env.workspace = Environ

# Create a Feature Dataset to store processing outputs
arcpy.CreateFeatureDataset_management(out_dataset_path=arcpy.env.workspace, out_name="devsde.SYOKLIC1.SpatialJoin_Output", spatial_reference="PROJCS['NAD_1983_HARN...']")

##I then create lists and loops to disable editor tracking and preform a spatial join 

# Update original features from spatial join layer records using SQL
sdeConn = arcpy.ArcSDESQLExecute(Environ)
query_list = ["Update...."]
for query in query_list:
        sdeConn.execute(query)

##Then delete the Feature Dataset that was created and re-enable editor tracking

2 Answers 2

1

The issue I am having is not a result of the script but incomplete knowledge of how versioning works. In order to do this I need to sync data from my SDE to an intermediate database, preform the updates on the intermediate database and then return the updates to the original SDE, after they have been QAQC.

Versioning does not prevent the creation or deletion of datasets from moving from child to parent versions, so my attempt to create output datasets from a spatial join and save them to my version resulted in a this data being created in the entire database not just my version.

0
0

Figured this out.

When you make your connection file, which you should be doing most of the time when you connect to sde, you need to assign the version parameter to your version. This puts edits made in the script in your version and not the default.

You need to make a table view to get around the error you're having when you try to change version. I use MakeTableView_management. It seems to work well enough. Once you do that, pass your table view to change version.

If that doesn't work for some reason comment on this answer and I'll try to help you out.

3
  • Hi @Steve, it has been a long time since I thought about this but I am fairly sure that my Database Connection was already hitting the version I wanted to update. That is why I named it DevVersion and not just Dev, but I have long since deleted that file. That is a useful note about the MakeTableView for changing versions.
    – Simon.y
    Commented Aug 29, 2018 at 19:11
  • My understanding is that using SQL does not track the adds and deletes to a specific version, it is hitting the table that the version is referencing. If you notice I don't even start and edit session, even if I am editing the Table View (_evw) in SQL Server, the database has not been told to track changes. I gave up on using ArcSDESQLExecute after looking more into it. If memory serves it was not intended to perform updates but to do more database maintenance tasks. I ended up using UpdateCursors to do this which was much easier, and it processes much faster!
    – Simon.y
    Commented Aug 29, 2018 at 19:15
  • @Simon.y That's what I normally use. I'm glad you told me. This will be useful for me later on. Generally I use a connection file to make a path to the feature class I want to edit or update that I actually can edit/update. I assign my version to that parameter, and if I need to I use the make table view change version trick. There's way too much overhead involved in messing with enterprise connections with arcpy.
    – user125266
    Commented Aug 29, 2018 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.