I have a script that has worked without issues when running against a file gdb, but am struggling to understand why it is not compatible as is for use with SQL gdb.
The error I get is
...line 31, in <module> cursor.updateRow(row)
NameError: name 'cursor' is not defined
<SPAN class="comment token"># Import system modules</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="comment token"># Set workspace and declare variables</SPAN>
workspace <SPAN class="operator token">=</SPAN> env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'Database Connections\mysql.default.sde'</SPAN>
fc <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Ramps_Copy'</SPAN>
fields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'BusStopsValue'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'City_and_PubValue'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Commercial_ZoningValue'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'MedicalValue'</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">'Parks_RecValue'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'SchoolsValue'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Social_ServValue'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Ped_CollisionsValue'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Start edit session</SPAN>
edit <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>Editor<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Set values to update</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN> fields<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># Assign values to categories</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Bus Stops</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># City & Public Facilities</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Commercial Zoning</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Medical Facilities</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Parks & Rec</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Schools</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">6</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">6</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Social Services</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">7</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">7</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Pedestrian-Related Collisions</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Cleanup</SPAN>
<SPAN class="keyword token">del</SPAN> row
<SPAN class="keyword token">del</SPAN> cursor
<SPAN class="comment token"># Stop edit sesion</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Any thoughts?
Paul