1

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'
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 18, 2016 at 16:37
0

1 Answer 1

3

As commented by @GISGe, the

arcpy.da.Editor [class] takes a workspace as argument: arcpy.da.Editor(workspace)

whereas you have:

edit = arcpy.da.Editor

See the Syntax section of the Editor class Help

answered Jan 25, 2017 at 7:45

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.