<?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.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1524448#M71281</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/560410"&gt;@RogerDunnGIS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp; An exception should be throw in these instances so I know what the issue is and where it is.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;While that sounds great in theory, it's actually pretty hard to accomplish, at least with enterprise geodatabases.&amp;nbsp; Data loading, for efficiency, is done as a bulk insert operation. This means that the error isn't encountered until &lt;U&gt;much&lt;/U&gt; later, possibly thousands of rows after the data has been staged for array insert.&amp;nbsp; If you organize your code to COMMIT after each row, then the error can be caught, BUT performance may be degraded by several orders of magnitude (e.g., 5 minutes instead of &lt;EM&gt;300 milliseconds&lt;/EM&gt;).&lt;/P&gt;&lt;P&gt;If no exception is &lt;U&gt;ever&lt;/U&gt; raised, then that &lt;STRONG&gt;is&lt;/STRONG&gt; a problem, and a reproducible test case should be submitted through Tech Support.&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;</description>
    <pubDate>Tue, 20 Aug 2024 16:14:41 GMT</pubDate>
    <dc:creator>VinceAngelo</dc:creator>
    <dc:date>2024-08-20T16:14:41Z</dc:date>
    <item>
      <title>arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522328#M71259</link>
      <description>&lt;P&gt;My Pro project contains an sde connection file called Knight.sde.&amp;nbsp; I am programming in a Notebook.&amp;nbsp; When I call arcpy.Describe on "Knight.sde" it shows me that it is indeed a Workspace and provides the full path to the file.&amp;nbsp; However, the following code yields the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.Editor("Knight.sde") as eddie:
  eddie.startEditing(True, True)
  try:
    eddie.startOperation()
    try:
        with arcpy.da.UpdateCursor("Feature Class") as u_cursor:
          for row in u_cursor:
            # some operation
        eddie.stopOperation()
        eddie.stopEditing(True)
    except:
      eddie.abortOperation()
      if "row" in locals():
        print(row)
      raise
  except:
    eddie.stopEditing(False)
    raise&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;AttributeError&lt;/SPAN&gt;                            Traceback (most recent call last)
In  &lt;SPAN class=""&gt;[65]&lt;/SPAN&gt;:
Line 2:     eddie.startEditing(&lt;SPAN class=""&gt;True&lt;/SPAN&gt;, &lt;SPAN class=""&gt;True&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN class=""&gt;AttributeError&lt;/SPAN&gt;: 'Workspace Operation object' object has no attribute 'startEditing'&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;If I print eddie's type in another cell, it shows 'Workspace Operation object' instead of any kind of editor object.&amp;nbsp; I am totally perplexed, as this pattern of programming has worked in the past.&amp;nbsp; I have tried a number of different parameters to the arcpy.da.Editor constructor and they all yield 'cannot open workspace' errors so I know that "Knight.sde" is the right thing to pass as an argument.&amp;nbsp; Why does my Editor constructor give me a weird Workspace Operation object instead?&amp;nbsp; It's like asking someone for an apple and getting a pinecone instead.&lt;/P&gt;&lt;P&gt;I am using ArcGIS Pro 3.3.1, the latest version available at this time.&amp;nbsp; I use an enterprise geodatabase on Microsoft SQL Server 2019 that is also the latest version of Esri's geodatabase format at this time, 11.3.0.52636.&amp;nbsp; I'm using the default Python environment that comes with Pro.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 16:08:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522328#M71259</guid>
      <dc:creator>RogerDunnGIS</dc:creator>
      <dc:date>2024-08-15T16:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522329#M71260</link>
      <description>&lt;P&gt;Also, calling dir(eddie) only yields a list of generic, special methods and properties (the kind that begin and end with two underscores).&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 16:10:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522329#M71260</guid>
      <dc:creator>RogerDunnGIS</dc:creator>
      <dc:date>2024-08-15T16:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522331#M71261</link>
      <description>&lt;P&gt;I think if you're using the&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.Editor("Knight.sde") as eddie:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;construction, you don't have to do the whole "Start editing/stop editing" thing; it gets taken care of for you.&lt;/P&gt;&lt;P&gt;Compare the samples on the documentation page:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/editor.htm" target="_blank" rel="noopener"&gt;Editor—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 16:13:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522331#M71261</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-08-15T16:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522384#M71262</link>
      <description>&lt;P&gt;You are mixing the two patterns of use for &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/editor.htm" target="_blank"&gt;Editor—ArcGIS Pro | Documentation.&lt;/A&gt;&amp;nbsp; In addition to the Esri documentation, there are lots of good primers online about the Python with statement and context managers.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 17:28:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522384#M71262</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2024-08-15T17:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522538#M71263</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; After looking over the Editor documentation for the n-th time, I noticed __enter__ and __exit__ methods, which do belong to this unknown Workspace Operation object.&amp;nbsp; I used the optional second parameter of the Editor constructor to indicate that this was a versioned dataset.&amp;nbsp; Your help will also help me fix two other scripts that broke with the 11.3 update.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 20:22:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522538#M71263</guid>
      <dc:creator>RogerDunnGIS</dc:creator>
      <dc:date>2024-08-15T20:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522541#M71264</link>
      <description>&lt;P&gt;Wait, why aren't the results showing in the attribute table, even after a table view refresh, version refresh, and closing and reopening the project?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 20:27:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522541#M71264</guid>
      <dc:creator>RogerDunnGIS</dc:creator>
      <dc:date>2024-08-15T20:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522554#M71265</link>
      <description>&lt;P&gt;I don't think the UpdateCursor is updating anything, even after I delete it after the edit session.&amp;nbsp; Even a SearchCursor yields the old values.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 20:52:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522554#M71265</guid>
      <dc:creator>RogerDunnGIS</dc:creator>
      <dc:date>2024-08-15T20:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522557#M71266</link>
      <description>&lt;P&gt;Seems like it definitely isn't.&lt;/P&gt;&lt;P&gt;Changes by Update Cursors are notorious for not showing up without a refresh, but since you've done that and also restarted the program...&lt;/P&gt;&lt;P&gt;What's your cursor stuff look like?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 20:59:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522557#M71266</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-08-15T20:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522996#M71269</link>
      <description>&lt;P&gt;I've tried many "iterations" of this script.&amp;nbsp; Either the script runs and doesn't update anything, or it yields some kind of exception.&amp;nbsp; Here is the current pattern:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;updates = 0
with arcpy.da.Editor("Knight.sde", True) as eddie:
    try:
        with arcpy.da.UpdateCursor(
            "Layer Name in Contents"
            , field_names=["PERMIT_NUMBER", "EMAIL1", "EMAIL2", "EMAIL3"]
            , where_clause="PERMIT_NUMBER IS NOT NULL") as update_cursor:
            for row in update_cursor:
                permit = row[0]
                # Magical data processing
                update_cursor.updateRow(row)
                updates += 1
    except:
        if "row" in locals():
            print("Row:", row)
        raise
    finally:
        if "update_cursor" in locals():
            del update_cursor
            print("update_cursor deleted")
        print(updates, "update(s)")&lt;/LI-CODE&gt;&lt;P&gt;The Notebook cell prints "update_cursor deleted" and then the number of updates performed.&amp;nbsp; It does not print the contents of a row or an exception.&amp;nbsp; I've tried various other print statements to compare the "old" row versus the "new" row and they look correct, but no such changes occur. The username in the Knight.sde file has UPDATE privileges on the feature class in question, and the feature class is in a versioned dataset.&lt;/P&gt;&lt;P&gt;I've done this kind of programming before at another job.&amp;nbsp; To me, it looks like a regression bug or something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 16:31:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1522996#M71269</guid>
      <dc:creator>RogerDunnGIS</dc:creator>
      <dc:date>2024-08-16T16:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1523001#M71270</link>
      <description>&lt;P&gt;Found the problem.&amp;nbsp; Palm to forehead.&lt;/P&gt;&lt;P&gt;One of the rows I'm updating during my "Magical data processing" phase, ends up with a string value whose length exceeds that of the field it's going into.&amp;nbsp; No exception is thrown, mind you, because the except block is never run, but that was why my table wasn't updating.&amp;nbsp; I only figured it out by adding Python code to test the length of the strings going back into the table.&lt;/P&gt;&lt;P&gt;Now, I'm guessing the wonderful "with" block handles the exception and doesn't re-raise it to let me, the developer, know that there's a problem with the data in updateRow.&amp;nbsp; That's just not fair!&amp;nbsp; It's not fair of Esri to not re-raise the exception.&amp;nbsp; What this means is that I'm going to have to do all the data validation prior to such scripts in the future, to make sure that strings aren't too long, that dates are valid, and that numbers aren't bigger than the precision and scale set for them.&amp;nbsp; That just ain't right.&amp;nbsp; An exception should be throw in these instances so I know what the issue is and where it is.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 16:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1523001#M71270</guid>
      <dc:creator>RogerDunnGIS</dc:creator>
      <dc:date>2024-08-16T16:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Editor(sde_workspace) yields a Workspace Operation object instead of an Editor</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1524448#M71281</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/560410"&gt;@RogerDunnGIS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp; An exception should be throw in these instances so I know what the issue is and where it is.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;While that sounds great in theory, it's actually pretty hard to accomplish, at least with enterprise geodatabases.&amp;nbsp; Data loading, for efficiency, is done as a bulk insert operation. This means that the error isn't encountered until &lt;U&gt;much&lt;/U&gt; later, possibly thousands of rows after the data has been staged for array insert.&amp;nbsp; If you organize your code to COMMIT after each row, then the error can be caught, BUT performance may be degraded by several orders of magnitude (e.g., 5 minutes instead of &lt;EM&gt;300 milliseconds&lt;/EM&gt;).&lt;/P&gt;&lt;P&gt;If no exception is &lt;U&gt;ever&lt;/U&gt; raised, then that &lt;STRONG&gt;is&lt;/STRONG&gt; a problem, and a reproducible test case should be submitted through Tech Support.&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 16:14:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-editor-sde-workspace-yields-a-workspace/m-p/1524448#M71281</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2024-08-20T16:14:41Z</dc:date>
    </item>
  </channel>
</rss>

