How do I add a feature class from an SDE to a Map in Pro? This is where most of our data is stored.
Here's what I've tried:
<SPAN class="keyword token">import</SPAN> arcpy
p <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CURRENT"</SPAN><SPAN class="punctuation token">)</SPAN>
map <SPAN class="operator token">=</SPAN> p<SPAN class="punctuation token">.</SPAN>listMaps<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token">#this returned a ValueError</SPAN>
map<SPAN class="punctuation token">.</SPAN>addLayer<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"Database Connections\path\to\gisedit.DBO.Address_Points"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#this returned a RuntimeError</SPAN>
map<SPAN class="punctuation token">.</SPAN>addDataFromPath<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"Database Connections\path\to\gisedit.DBO.Address_Points"</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>
All the methods for using classes seem to be referencing layer files, and nowhere do I see a reference to feature classes.
Alphabetical list of arcpy.mp classes—ArcPy | ArcGIS Desktop
EDIT:
The confusing thing is that when feature classes from the SDE are in the Map they're referred to as layers. The CURRENT project I'm testing on already has two feature classes from an SDE in it. You can list them with the following:
<SPAN class="keyword token">for</SPAN> lyrname <SPAN class="keyword token">in</SPAN> map<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>lyrname<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>