Python arcpy.InsertCursor Does not work in SDE

1302
6
03-03-2016 07:45 AM
JoseSanchez
Occasional Contributor III

Hello everyone,

I am running the Python code below first pointing to an SDE layer and then pointing to a FGDB layer and in the first case after the program finish nothing gets inserted in SDE. It works in the FGDB.

The layer in SDE is not versioned.

I can Append layers from the FGDB to SDE using:  arcpy.Append_management(

What am I missing?

curAppend = arcpy.InsertCursor(WASDAGREEMENT_D)


  .....


  rowAppend = curAppend.newRow()
  rowAppend.SHAPE = rowYesterday.SHAPE
  rowAppend.AGMID = rowYesterday.getValue("AGMID")
  rowAppend.DIGIBY =  rowYesterday.getValue("DIGIBY")
  rowAppend.DIGIDATE =  rowYesterday.getValue("DIGIDATE")
  rowAppend.STATUS =  rowYesterday.getValue("STATUS")
  rowAppend.REQUESTED =  rowYesterday.getValue("REQUESTED")
  rowAppend.PNAME =  rowYesterday.getValue("PNAME")
  rowAppend.PLOCATION =  rowYesterday.getValue("PLOCATION")
  rowAppend.PDESC =  rowYesterday.getValue("PDESC")
      
  curAppend.insertRow(rowAppend)
0 Kudos
6 Replies
WesMiller
Regular Contributor III

Are you using a del statement for your curAppend? If your not your changes won't show until you close your python IDE

InsertCursor—Help | ArcGIS for Desktop

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

Wes, for some reason I am getting an error on you link.  Might want to check it.

0 Kudos
WesMiller
Regular Contributor III

Thanks must be something wrong with the links again.

copy and paste in your browser this path without the quotes

"http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-data-access/insertcursor-class.htm"

0 Kudos
JoseSanchez
Occasional Contributor III

This same code works fine when I point to a layer in a FGDB but it does nthing when I point to the same king of layer in SDE.

0 Kudos
XanderBakker
Esri Esteemed Contributor

True, because most likely you will need to set up the edit session in your Python script. Did you try this?

0 Kudos
XanderBakker
Esri Esteemed Contributor

You probably have to start an edit session as explained in code sample 2 at the end of this page: Editor—Help | ArcGIS for Desktop