<?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: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597144#M46756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post your code you are running again? The only lines you should need are these&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy workspace = "Database Connections\\CCENTGIS_SCLFinal_PRSCL_test.sde\\prscl_test.SCLADMIN.GMSCL" fc = "prscl_test.SCLADMIN.sclarc" arcpy.env.workspace = workspace arcpy.MakeFeatureLayer_management(fc, "sclarc_layer") with arcpy.da.Editor(workspace) as edit: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management("sclarc_layer", "STRNAME", "!strname!.strip", "PYTHON_9.3", "")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Jul 2013 17:14:07 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2013-07-18T17:14:07Z</dc:date>
    <item>
      <title>Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597135#M46747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to do a simple edit using Calculate field on a layer in a versioned SDE GDB. I've gotten past a few errors, but now have ran into a new one that I can seem to get past. The error is "Objects in this class cannot be updated outside an edit session". I'm trying to use arcpy.da.Editor, but I seem to be missing something.&amp;nbsp; Any ideas would be greatly appreciated! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;fc = "Database Connections\\CCENTGIS_SCLFinal_PRSCL_test.sde\\prscl_test.SCLADMIN.GMSCL\\prscl_test.SCLADMIN.sclarc" workspace = "Database Connections\\CCENTGIS_SCLFinal_PRSCL_test.sde"&amp;nbsp; arcpy.MakeFeatureLayer_management(fc, "sclarc_layer")&amp;nbsp; edit = arcpy.da.Editor(workspace)&amp;nbsp; edit.startEditing() edit.startOperation()&amp;nbsp; with arcpy.da.Editor(workspace) as edit: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management("sclarc_layer", "STRNAME", "!strname!.strip", "PYTHON_9.3", "")&amp;nbsp; edit.stopOperation() edit.stopEditing(True) &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 19:47:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597135#M46747</guid>
      <dc:creator>JaimeMcKeown</dc:creator>
      <dc:date>2013-07-17T19:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597136#M46748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe you need to set your workspace to your feature dataset, not the general database.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 19:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597136#M46748</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-17T19:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597137#M46749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When I set the workspace to the dataset I get "runtime error: cannot open workspace".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 20:31:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597137#M46749</guid>
      <dc:creator>JaimeMcKeown</dc:creator>
      <dc:date>2013-07-17T20:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597138#M46750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you connected with a version user that can make edits?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 21:06:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597138#M46750</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-17T21:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597139#M46751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to edit a test version of the database, and it turns out it wasn't setup properly.&amp;nbsp; Now that's fixed and I can edit, but it still won't run properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my latest error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "G:\prscl\appl\Python\Scl_qcarcs_test.py", line 20, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; edit.stopOperation()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'Workspace Operation object' object has no attribute 'stopOperation'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 14:09:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597139#M46751</guid>
      <dc:creator>JaimeMcKeown</dc:creator>
      <dc:date>2013-07-18T14:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597140#M46752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah yes you'll have to have those inside your with statement as afterwards your edit variable is closed automatically.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 14:22:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597140#M46752</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-18T14:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597141#M46753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I moved edit.stopOperation() and edit.stopEditing() into the statement and I still get the same error.&amp;nbsp; I'm beginning to think this isn't going to work...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 15:09:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597141#M46753</guid>
      <dc:creator>JaimeMcKeown</dc:creator>
      <dc:date>2013-07-18T15:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597142#M46754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried removing those lines completely? The help examples shows just the with statement as able to stop and close the edit session automatically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000005000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000005000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.Editor(workspace) as edit:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer_name, 'Usage', '"PUBLIC"', 'PYTHON')&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:37:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597142#M46754</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T01:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597143#M46755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did and it still doesn't work, very frustrating...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 16:57:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597143#M46755</guid>
      <dc:creator>JaimeMcKeown</dc:creator>
      <dc:date>2013-07-18T16:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597144#M46756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post your code you are running again? The only lines you should need are these&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy workspace = "Database Connections\\CCENTGIS_SCLFinal_PRSCL_test.sde\\prscl_test.SCLADMIN.GMSCL" fc = "prscl_test.SCLADMIN.sclarc" arcpy.env.workspace = workspace arcpy.MakeFeatureLayer_management(fc, "sclarc_layer") with arcpy.da.Editor(workspace) as edit: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management("sclarc_layer", "STRNAME", "!strname!.strip", "PYTHON_9.3", "")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jul 2013 17:14:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597144#M46756</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-18T17:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script</title>
      <link>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597145#M46757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It finally works!&amp;nbsp; The example you just sent worked once I set the workspace only to the database and not the dataset.&amp;nbsp; The longer way that I was trying also works after I changed the object on the statement.&amp;nbsp; I did'nt realize that I needed to use a differenct object from the one I used above.&amp;nbsp; My boss that hasn't been available for 2 days final came to help as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are both scripts that finally worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
workspace = "Database Connections\\PRSCL_TEST_SCLAdmin.sde"
fc = "prscl_test.SCLADMIN.sclarc"
arcpy.env.workspace = workspace
arcpy.MakeFeatureLayer_management(fc, "sclarc_layer")
with arcpy.da.Editor(workspace) as edit:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management("sclarc_layer", "STRNAME", "!strname!.upper()", "PYTHON_9.3", "")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
workspace = "Database Connections\\PRSCL_TEST_SCLAdmin.sde"
fc = "prscl_test.SCLADMIN.sclarc"
arcpy.env.workspace = workspace
arcpy.MakeFeatureLayer_management(fc, "sclarc_layer")
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
with arcpy.da.Editor(workspace) as fieldEdit:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(fcLayer, "STRNAME", "!strname!.upper()", "PYTHON_9.3", "")
edit.stopOperation()
edit.stopEditing(True)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much for your help!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:37:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/trying-to-edit-a-layer-in-a-versioned-sde-gdb-in-a/m-p/597145#M46757</guid>
      <dc:creator>JaimeMcKeown</dc:creator>
      <dc:date>2021-12-12T01:37:58Z</dc:date>
    </item>
  </channel>
</rss>

