<?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: Error updating a database with da.UpdateCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504905#M39656</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is both using the mxd variable and deleting the mxd variable within the for loop.&amp;nbsp; That will cause an error if the steps in the loop are executed more than one time.&amp;nbsp; Repeating steps more than once is kind of the point of using a for loop, so make sure you only delete variables within a for loop that are created inside the for loop, otherwise you should dedent the del statement to remove it from the for loop and only execute it once after the for loop has been completed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the surface, everything seems to be OK as far as declaring the cursor, updating the 7th field of the current row and updating the row using the cursor.&amp;nbsp; That assumes that the map_created field is a numeric field and not a string field or some other type of field.&amp;nbsp; However, since you are performing this edit within an Editor session I&amp;nbsp;assume the data is versioned.&amp;nbsp; Does this data use any other advanced&amp;nbsp;settings that require an Editor session, such as it's a geometric network or anything else?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Aug 2019 14:37:20 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2019-08-29T14:37:20Z</dc:date>
    <item>
      <title>Error updating a database with da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504904#M39655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been trying to run a loop on a table in a database and then want to change one field in the table so the next time this runs, it doesn't repeat actions.&amp;nbsp; I am experiencing problems updating the table.&amp;nbsp; Here is the code where I think the problems are occurring:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #6a9955;"&gt;# import xlrd - used to help read excel files&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #c586c0;"&gt;import&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #c586c0;"&gt;import&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; os&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #c586c0;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy &lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;import&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; env&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;TemplateLocation &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;MKRAMER\Share&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\F&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;ig1AutomationProject&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\R&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;equired Files"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;ProjectLocation &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;MKRAMER\Share&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\F&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;ig1AutomationProject"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;OutputLocation &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; ProjectLocation &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;Output Files"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt;projTable &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;'C:&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\U&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;sers&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\m&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;kramer\AppData&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\R&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;oaming&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\E&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;SRI\Desktop10.7\ArcCatalog&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\C&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;onnection to ACCTG-SQL.sde&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\P&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;rojectLocations.dbo.SiteMapList'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #6a9955;"&gt;#projTable.definitionQuery = "\"WBS1\" = '185-202' AND \"WBS2\" = ''"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #c586c0;"&gt;try&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #6a9955;"&gt;#sets data pulled from the database to variables&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #6a9955;"&gt;# Changing the aspects of the environment to allow overrides&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy.env.workspace &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; projTable&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy.env.overwriteOutput &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;True&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #6a9955;"&gt;# starts an edit session to change values&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; edit &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy.da.Editor(os.path.dirname(projTable))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; edit.startEditing(&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;False&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;True&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; edit.startOperation()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;with&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy.da.UpdateCursor(projTable, [&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'WBS1'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'WBS2'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Longitude'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'Latitude'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'ProjName'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'ClientName'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'City'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'map_created'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;],&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\"&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;map_created&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\"&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt; = '0'"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; cursor:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #dcdcaa;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"Start Loop"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; row &lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; cursor:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;and then I get the error when I try to update the row at the bottom of the for loop here:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.RefreshTOC() &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mxd.saveACopy(ProjectLocation &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; projectNumber.replace(&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"-"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"_SiteLocationMap.mxd"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.mapping.ExportToPDF(mxd, ProjectLocation &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; projectNumber.replace(&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"-"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;""&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"_SiteLocationMap.pdf"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;image_quality&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"NORMAL"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;row[&lt;/SPAN&gt;&lt;SPAN style="color: #b5cea8;"&gt;7&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;] &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #b5cea8;"&gt;1&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cursor.updateRow(row)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #c586c0;"&gt;del&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; mxd, df, insetDF&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #dcdcaa;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"End Loop"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; edit.stopOperation()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; edit.stopEditing(true)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the error I am throwing:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "//MKRAMER/Share/Fig1AutomationProject/AutomationScript.py", line 164, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;BR /&gt;SystemError: error return without exception set&lt;/BLOCKQUOTE&gt;&lt;P&gt;I apologize for any formatting issues, first time poster here.&amp;nbsp; If there is anything I left out that could be of help, just let me know.&amp;nbsp; Thank you for any help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 13:56:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504904#M39655</guid>
      <dc:creator>MatthewKramer</dc:creator>
      <dc:date>2019-08-29T13:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Error updating a database with da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504905#M39656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is both using the mxd variable and deleting the mxd variable within the for loop.&amp;nbsp; That will cause an error if the steps in the loop are executed more than one time.&amp;nbsp; Repeating steps more than once is kind of the point of using a for loop, so make sure you only delete variables within a for loop that are created inside the for loop, otherwise you should dedent the del statement to remove it from the for loop and only execute it once after the for loop has been completed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the surface, everything seems to be OK as far as declaring the cursor, updating the 7th field of the current row and updating the row using the cursor.&amp;nbsp; That assumes that the map_created field is a numeric field and not a string field or some other type of field.&amp;nbsp; However, since you are performing this edit within an Editor session I&amp;nbsp;assume the data is versioned.&amp;nbsp; Does this data use any other advanced&amp;nbsp;settings that require an Editor session, such as it's a geometric network or anything else?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 14:37:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504905#M39656</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2019-08-29T14:37:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error updating a database with da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504906#M39657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am creating a standard map from a template and saving a copy and exporting the map at the end of each loop.&amp;nbsp; I want to keep the template map the same so I have a fresh map each iteration.&amp;nbsp; I didn't include the declaration in the first picture but I initialize the mxd variable in the first line of the for loop.&amp;nbsp; The data is a SQL-Server and the map_created field is a short integer.&amp;nbsp; I am not sure if the data is versioned but the code does not run without the edit commands in there either.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 14:50:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504906#M39657</guid>
      <dc:creator>MatthewKramer</dc:creator>
      <dc:date>2019-08-29T14:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: Error updating a database with da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504907#M39658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured it out, I believe since the database I am working with isn't a geodatabase I had to use ArcSDESQLExecute to reconnect and make my own update query to make the change.&amp;nbsp; Code to do that below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-family: Consolas, 'Courier New', monospace; font-weight: normal; font-size: 14px; line-height: 19px; white-space: pre;"&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; SQLConnection &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; arcpy.ArcSDESQLExecute(&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;r&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;'C:&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\U&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;sers&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\m&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;kramer\AppData&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\R&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;oaming&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\E&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;SRI\Desktop10.7\ArcCatalog&lt;/SPAN&gt;&lt;SPAN style="color: #d7ba7d;"&gt;\C&lt;/SPAN&gt;&lt;SPAN style="color: #d16969;"&gt;onnection to ACCTG-SQL.sde'&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="color: #d4d4d4;"&gt; SQLQuery &lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; SQLConnection.execute(&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;"update ProjectLocations.dbo.SiteMapList set map_created=1 where WBS1='&lt;/SPAN&gt;&lt;SPAN style="color: #569cd6;"&gt;{0}&lt;/SPAN&gt;&lt;SPAN style="color: #ce9178;"&gt;'"&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.format(projectNumber))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:09:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504907#M39658</guid>
      <dc:creator>MatthewKramer</dc:creator>
      <dc:date>2019-08-29T15:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error updating a database with da.UpdateCursor</title>
      <link>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504908#M39659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is interesting that a da cursor wouldn't work with your SQL-Server set up, since I have used da cursors with my SQL-Server set up, but I assume there are a variety of ways to configure SQL-Server and that your set up and mine could be different is some significant way.&amp;nbsp; Anyway, I am glad there is support for controlling SQL-Server using commands that are more native to that database that are working for you.&amp;nbsp; It did seem like the SDE component was the likely culprit&amp;nbsp;behind your problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:30:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-updating-a-database-with-da-updatecursor/m-p/504908#M39659</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2019-08-29T15:30:56Z</dc:date>
    </item>
  </channel>
</rss>

