Select to view content in your preferred language

Why InsertCursor does not work in an enterprise geodatabse?

1406
4
Jump to solution
11-01-2020 06:34 AM
Amadeus111
Frequent Contributor
from vrbls import *

arcpy.env.workspace = database
workspace = arcpy.env.workspace
arcpy.env.overwriteOutput = True
edit = arcpy.da.Editor(workspace)

edit.startEditing(False, True)
edit.startOperation()
insert_cursor = arcpy.da.InsertCursor(perm_bound, ["PermitNo", "FeatCLS", "Contact", "Source",
                                                   "National_ID", "Type_Flag", "Calc_Acres", 'SHAPE@'])
with arcpy.da.SearchCursor(perm_bound_file_geodb, ["PermitNo", "FeatCLS", "Contact", "Source", "National_ID",
                                                   "Type_Flag", "Calc_Acres", 'SHAPE@']) as cursor:
    for row in cursor:
        insert_cursor.insertRow(row)
        print('row inserted')

    del cursor
del insert_cursor
edit.startEditing(False, True)
edit.startOperation()

I do not have any problem using this code in a file geodatabase and it works fine. It does not work inside an enterprise geodatabase and does not insert any rows yet I do not get any error and it exits with zero code. 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

Is the EGDB versioned? Where is stopOperation() and stopEditing(True)?

you may have luck with edit.startEditing(False, False)

View solution in original post

4 Replies
JoeBorgione
MVP Emeritus

Does your user have the correct permissions on that feature class on the egdb?

That should just about do it....
0 Kudos
Amadeus111
Frequent Contributor

@Joe-Borgione Thank you for your answer. I have DBO and Admin credentials I am the one who run the scripts. I use the Admin connection on the data will be updated.

database = r'\\nrdsmnt6\mine maps\DMP_Database\ShapefileProcessing_SupportFiles\Connection_DMP_Admin.sde'

Should I do something else? I can not use append tool here because there are read locks and I am unable to remove locks to switch "unregister as versioned". 

0 Kudos
DavidPike
MVP Frequent Contributor

Is the EGDB versioned? Where is stopOperation() and stopEditing(True)?

you may have luck with edit.startEditing(False, False)

Amadeus111
Frequent Contributor

Thanks a lot @David-Pike, I copied and pasted the wrong lines. duh! exactly, where is stopOperation() and stopEditing(True) I did not even notice I did not stop editing. That was the problem.