Select to view content in your preferred language

Edit Versioned Feature Class in python

8117
2
07-09-2014 01:00 PM
BrendanDwyer
Frequent Contributor

I have a versioned feature class in sde that is the source of a map service.  I can open the feature class in arc map, start an edit session, make edits and save those edits.  However, if I try to start an edit session in an arcpy script I get a schema lock.  I'm using the same user and sde connection file.  Shouldn't I be able to edit this feature class in arcpy? 

Tags (3)
0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Brendan,

Can you post the code you are using?  Here is an example of editing a versioned feature class:

import arcpy

import os

fc = 'Database Connections/VECTOR@SQLSERVER.sde/AddressPts'

workspace = os.path.dirname(fc)

# Start an edit session. Must provide the worksapce.

edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data

#  (for second argument, use False for unversioned data)

edit.startEditing(False, True)

# Start an edit operation

edit.startOperation()

# Insert a row into the table.

with arcpy.da.InsertCursor(fc, ('SHAPE@', 'Address')) as icur:

    icur.insertRow([(601181.055124, 762555.994028), '120 Main St'])

# Stop the edit operation.

edit.stopOperation()

# Stop the edit session and save the changes

edit.stopEditing(True)

BrendanDwyer
Frequent Contributor

Jake,

Thanks for responding.  I ended up using the append tool instead.

The idea is that another department posts an excel file online and we want to update a feature class with the new data.  We want to completely replace the existing records with the new data.  So I am using the delete rows tool then the append tool instead of opening an edit session with a data access cursor.

0 Kudos