I have a simple script that I use to select features from a ArcSDE database and export them to a personal.gdb.
Currently, I have to manually save and stop my edit session in the MXD so that the script can get a schema lock.
I have been trying to use arcpy.da.Editor at the start of the script to automatically end the edit session, but I have not been able to achieve that thus far.
Is this the correct way to end an edit session in the MXD I am running the script in? I would also like to be able to restart my edit session after the script runs.
import arcpy import os from arcpy import env env.overwriteOutput = True edit = arcpy.da.Editor edit.startEditing(False, True) print 'Stopping Edit' # Delete Feature class from file Geodatabase arcpy.Delete_management('C:\GIS\BlairMailer\Mailer.mdb\AddressPoint') print 'Feature Class Deleted' # Select by attribute arcpy.SelectLayerByAttribute_management ( "AddressPoint", "NEW_SELECTION", " [DISTRICT] = 'Y'" or "[DISTRICT] = 'y'") # Export selected feature to Geodatabase arcpy.FeatureClassToGeodatabase_conversion("AddressPoint",'C:\GIS\BlairMailer\Mailer.mdb') print 'feature Class Exported' # Open Mailer os.startfile(r'C:\GIS\BlairMailer\Mailer.docx')
This is the returned error when I try to run the script with an active edit session.
Runtime error Traceback (most recent call last): File "<string>", line 7, in <module> TypeError: descriptor 'startEditing' requires a 'Workspace Editor' object but received a 'bool'