1

I am a beginner with Python and ArcPy.

I am trying to write a Python script that will overwrite the viewer copy of our data with the most recent editor copy. Here is the code I am running through the Python window:

import arcpy
import os
arcpy.AcceptConnections(TargetDB, False)
time.sleep(1)
arcpy.DisconnectUser(TargetDB, "ALL")
time.sleep(1)
arcpy.conversion.FeatureClassToFeatureClass(EditorFC, OldDataPath, "TaxParcel")
time.sleep(1)
arcpy.AcceptConnections(TargetDB, True)

Upon running that, however, I get the following error message:

Traceback (most recent call last):
 File "<string>", line 7, in <module>
 File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 3204, in FeatureClassToFeatureClass
 raise e
 File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 3201, in FeatureClassToFeatureClass
 retval = convertArcObjectToPythonObject(gp.FeatureClassToFeatureClass_conversion(*gp_fixargs((in_features, out_path, out_name, where_clause, field_mapping, config_keyword), True)))
 File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
 return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 000601: Cannot delete C:\Users\GISuser\AppData\Roaming\Esri\ArcGISPro\Favorites\OCGIS21 - Vector - GISuser.sde\OCGIS21_Vector.DBO.ParcelPublishing\OCGIS21_Vector.DBO.TaxParcel. May be locked by another application.
Failed to execute (FeatureClassToFeatureClass).

What am I doing wrong?

Once I get this straightened out, my plan is to export this as a Python file to run through windows task scheduler on a nightly basis.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 8, 2022 at 15:45
3
  • Well, the table is locked.. Maybe you need this - just a guess pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/… Commented Sep 8, 2022 at 16:44
  • 1
    If you run arcpy.ListUsers(TargetDB) after running arcpy.DisconnectUser(TargetDB, "ALL"), it will list in a tuple what users were not disconnected. I've had to use time.sleep() before as well for overwriting items, but typically use time.sleep(5). If you continue to have users after running DisconnectUser, then you may not be using an SDE connection with administrative rights on the SDE. Also, you may want to consider enabling overwrites by setting the environment variable to allow it. arcpy.env.overwriteOutput = True Commented Sep 8, 2022 at 16:48
  • 1
    @evv_gis I ended up solving the issue. It was due to that feature class participating in a topology. Removing it from the topology cleared that error message. Thank you for your help! Commented Sep 8, 2022 at 17:07

1 Answer 1

1

I ended up solving the problem. The feature class in question participated in a topology, which creates a lock on that feature class that is not removed by arcpy.DisconnectUser. Removing it from the topology solved the issue.

answered Sep 8, 2022 at 17:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.