<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy.ad.InsertCursor locking SDE data base in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-locking-sde-data-base/m-p/685813#M53083</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I'm having an issue with using the new da cursors in Arc 10.1. I have a basic script that uses selected features ("watpoints") and copies them to an abandoned layer (watabdev)&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.MakeFeatureLayer_management(point,"watpoints")
with arcpy.da.InsertCursor(watabdev,("SUBTYPE","SHAPE@XY")) as cur:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor("watpoints",["SHAPE@XY"]) as cursor:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.insertRow((1,row[0]))
del cur, row, cursor
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I used with cursors and tried deleting the cursors afterwords. But after I run the tool, arcmap gives me an error that the abandoned layer is in a closed state and I cannot access it.&lt;BR /&gt;&lt;BR /&gt;Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"The advantage of using a With statement is that it will guarantee close and release of database locks and reset iteration regardless of whether the cursor completed successfully or an exception occurred."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That would imply the del statements are not needed.&amp;nbsp; Have you tried the script without them?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:51:05 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2021-12-12T04:51:05Z</dc:date>
    <item>
      <title>arcpy.da.InsertCursor locking SDE data base</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-locking-sde-data-base/m-p/685812#M53082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having an issue with using the new da cursors in Arc 10.1. I have a basic script that uses selected features ("watpoints") and copies them to an abandoned layer (watabdev)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
arcpy.MakeFeatureLayer_management(point,"watpoints")
with arcpy.da.InsertCursor(watabdev,("SUBTYPE","SHAPE@XY")) as cur:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor("watpoints",["SHAPE@XY"]) as cursor:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.insertRow((1,row[0]))
del cur, row, cursor
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I used with cursors and tried deleting the cursors afterwords. But after I run the tool, arcmap gives me an error that the abandoned layer is in a closed state and I cannot access it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2013 20:06:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-locking-sde-data-base/m-p/685812#M53082</guid>
      <dc:creator>JeremyLuymes</dc:creator>
      <dc:date>2013-10-24T20:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.ad.InsertCursor locking SDE data base</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-locking-sde-data-base/m-p/685813#M53083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I'm having an issue with using the new da cursors in Arc 10.1. I have a basic script that uses selected features ("watpoints") and copies them to an abandoned layer (watabdev)&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
arcpy.MakeFeatureLayer_management(point,"watpoints")
with arcpy.da.InsertCursor(watabdev,("SUBTYPE","SHAPE@XY")) as cur:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor("watpoints",["SHAPE@XY"]) as cursor:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.insertRow((1,row[0]))
del cur, row, cursor
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I used with cursors and tried deleting the cursors afterwords. But after I run the tool, arcmap gives me an error that the abandoned layer is in a closed state and I cannot access it.&lt;BR /&gt;&lt;BR /&gt;Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the help:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"The advantage of using a With statement is that it will guarantee close and release of database locks and reset iteration regardless of whether the cursor completed successfully or an exception occurred."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That would imply the del statements are not needed.&amp;nbsp; Have you tried the script without them?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:51:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-insertcursor-locking-sde-data-base/m-p/685813#M53083</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T04:51:05Z</dc:date>
    </item>
  </channel>
</rss>

