<?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: Cannot Update Outside of an Edit Session in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414467#M70441</link>
    <description>&lt;P&gt;Is it versioned, moving edit to base?&lt;/P&gt;&lt;P&gt;Also,&amp;nbsp;&lt;A href="http://import%20arcpy, os  sde =  r&amp;quot;C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset&amp;quot; fc = r&amp;quot;C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset\FeatureClass&amp;quot; workspace = os.path.dirname(sde)  edit = arcpy.da.Editor(workspace) edit.startEditing(False, True) edit.startOperation()  arcpy.management.DeleteRows(fc)      edit.stopOperation() edit.stopEditing(True" target="_self"&gt;Truncate Table&lt;/A&gt; can not be used on versioned data.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2024 22:44:05 GMT</pubDate>
    <dc:creator>RhettZufelt</dc:creator>
    <dc:date>2024-04-23T22:44:05Z</dc:date>
    <item>
      <title>Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414328#M70439</link>
      <description>&lt;P&gt;There are several previous posts about this but I can't seem to figure this out.&lt;/P&gt;&lt;P&gt;I have a versioned feature class that I am trying to write a python script for that will remove all the data from the table using either TruncateTable or DeleteRows. I have tried to start an edit session prior to this function but I keep getting the "Cannot Update Outside of an Edit Session" error. Code below. Any ideas what I'm doing wrong?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os

sde =  r"C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset"
fc = r"C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset\FeatureClass"
workspace = os.path.dirname(sde)

edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()

arcpy.management.DeleteRows(fc)
    
edit.stopOperation()
edit.stopEditing(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 18:33:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414328#M70439</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-04-23T18:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414353#M70440</link>
      <description>&lt;P&gt;Can the Workspace be a feature class or feature dataset?&amp;nbsp;&amp;nbsp;&lt;BR /&gt;I've always set the workspace as a .gdb or .sde&lt;BR /&gt;&lt;BR /&gt;I'm curious if it works if you set the workspace as:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;r"C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 19:05:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414353#M70440</guid>
      <dc:creator>Tom_Laue</dc:creator>
      <dc:date>2024-04-23T19:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414467#M70441</link>
      <description>&lt;P&gt;Is it versioned, moving edit to base?&lt;/P&gt;&lt;P&gt;Also,&amp;nbsp;&lt;A href="http://import%20arcpy, os  sde =  r&amp;quot;C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset&amp;quot; fc = r&amp;quot;C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset\FeatureClass&amp;quot; workspace = os.path.dirname(sde)  edit = arcpy.da.Editor(workspace) edit.startEditing(False, True) edit.startOperation()  arcpy.management.DeleteRows(fc)      edit.stopOperation() edit.stopEditing(True" target="_self"&gt;Truncate Table&lt;/A&gt; can not be used on versioned data.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 22:44:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414467#M70441</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-04-23T22:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414639#M70445</link>
      <description>&lt;P&gt;Thanks for the reply&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/299157"&gt;@Tom_Laue&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;The os.path.dirname(sde) takes off the feature dataset from the path and leaves only "C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde" - but not sure if this is the best way to do this.&lt;BR /&gt;&lt;BR /&gt;I tried setting workspace as the sde connection, but I got the same results.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 12:12:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414639#M70445</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-04-24T12:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414640#M70446</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&amp;nbsp;Yes, it is versioned, moving edits to base.&lt;/P&gt;&lt;P&gt;Good to know about truncate table - thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 12:12:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414640#M70446</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-04-24T12:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414776#M70448</link>
      <description>&lt;P&gt;This is working for me on a SDE featureclass, versioned, moving edits to base.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy, os

sde = r"C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde"
fc = r'C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset\FeatureClass'

edit = arcpy.da.Editor(sde)
edit.startEditing(False, True)
edit.startOperation()
    
arcpy.management.DeleteRows(fc)
    
edit.stopOperation()
edit.stopEditing(True)&lt;/LI-CODE&gt;&lt;P&gt;Not sure, but suspect it has something to do with the workspace path.&lt;/P&gt;&lt;P&gt;You say that os.path.dirname(sde) is reporting:&amp;nbsp;&lt;SPAN&gt;"C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is that when you print(workspace), or just enter workspace at the prompt?&amp;nbsp; If this is the actual path being sent to the editor (just typing workspace at the prompt), then it will have issues.&amp;nbsp; &amp;nbsp;The editor is expecting "C:\\Users\\User\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\sdeConnection.sde".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So, if the above code still doesn't work, I'd try hardcoding the workspace to see if it is related to that.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;edit = arcpy.da.Editor(r"C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde")&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Should at least help narrow down the issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 15:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414776#M70448</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-04-24T15:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414782#M70449</link>
      <description>&lt;P&gt;Also, if it is a large table with no attachments (since truncate won't truncated associated attachments tables) it may be faster to &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/unregister-as-versioned.htm" target="_self"&gt;unregister as versioned&lt;/A&gt;, truncate, then re-&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/register-as-versioned.htm" target="_self"&gt;register as versioned&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 16:32:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1414782#M70449</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-04-24T16:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1415288#M70461</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/15530"&gt;@RhettZufelt&lt;/a&gt;&lt;/P&gt;&lt;P&gt;When I put&amp;nbsp;&lt;SPAN&gt;"C:\\Users\\User\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\sdeConnection.sde" in the sde variable, it worked! It seems for some reason it doesn't like the raw string syntax for the sde path. Any idea why that could be?&lt;BR /&gt;&lt;BR /&gt;See below for what worked for me, noting the changes at the sde variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os

sde = "C:\\Users\\User\\AppData\\Roaming\\Esri\\ArcGISPro\\Favorites\\sdeConnection.sde"
fc = r"C:\Users\User\AppData\Roaming\Esri\ArcGISPro\Favorites\sdeConnection.sde\FeatureDataset\FeatureClass"


edit = arcpy.da.Editor(sde)
edit.startEditing(False, True)
edit.startOperation()

arcpy.management.DeleteRows(fc)
    
edit.stopOperation()
edit.stopEditing(True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 13:32:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1415288#M70461</guid>
      <dc:creator>JoshBillings</dc:creator>
      <dc:date>2024-04-25T13:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Update Outside of an Edit Session</title>
      <link>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1415322#M70462</link>
      <description>&lt;P&gt;My testing had no issue with the raw string path if I set it directly in the arcpy.da.Editor(sde) instead of using workspace variable, but after the os.path.dirname(sde) it was having issues.&lt;/P&gt;&lt;P&gt;Not sure, I think it was returning the path as a string, not raw string so wasn't valid as input.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1714056143237.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/102145iDF49F52E6E2F4334/image-size/large?v=v2&amp;amp;px=999" role="button" title="RhettZufelt_0-1714056143237.png" alt="RhettZufelt_0-1714056143237.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 14:43:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-update-outside-of-an-edit-session/m-p/1415322#M70462</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2024-04-25T14:43:51Z</dc:date>
    </item>
  </channel>
</rss>

