<?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 Load SQL View on ArcMap, using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/load-sql-view-on-arcmap-using-python/m-p/741701#M57334</link>
    <description>&lt;P&gt;I want to add a sql view, generated in slq server, on ArcMap document,&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;through python script.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My sql view has this fields:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/397350_pastedImage_2.png" border="0" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/397351_pastedImage_3.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My script is:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;lyr = arcpy.mapping.Layer(r'Database Connections\xyzxy.sde\xyzx.dbo.Lay1')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.mapping.AddLayer(df,lyr)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This script load lyr on ArcMap temporaly, but when I want to acces to Attribute table, see this error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/397349_pastedImage_1.png" border="0" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I don´t know how to indicate to python, wich field from Lay1 contain oid, in my case OBJECTID field&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I guess your help, thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jun 2024 20:12:46 GMT</pubDate>
    <dc:creator>Autoridad_Nacional_del_AguaANA</dc:creator>
    <dc:date>2024-06-28T20:12:46Z</dc:date>
    <item>
      <title>Load SQL View on ArcMap, using Python</title>
      <link>https://community.esri.com/t5/python-questions/load-sql-view-on-arcmap-using-python/m-p/741701#M57334</link>
      <description>&lt;P&gt;I want to add a sql view, generated in slq server, on ArcMap document,&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;through python script.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My sql view has this fields:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/397350_pastedImage_2.png" border="0" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/397351_pastedImage_3.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My script is:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;lyr = arcpy.mapping.Layer(r'Database Connections\xyzxy.sde\xyzx.dbo.Lay1')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.mapping.AddLayer(df,lyr)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This script load lyr on ArcMap temporaly, but when I want to acces to Attribute table, see this error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/397349_pastedImage_1.png" border="0" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I don´t know how to indicate to python, wich field from Lay1 contain oid, in my case OBJECTID field&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I guess your help, thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jun 2024 20:12:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/load-sql-view-on-arcmap-using-python/m-p/741701#M57334</guid>
      <dc:creator>Autoridad_Nacional_del_AguaANA</dc:creator>
      <dc:date>2024-06-28T20:12:46Z</dc:date>
    </item>
  </channel>
</rss>

