There must be a way to do Add Data from a .gdb using Python. I looked it up but could not find not one hit.
To add to the above responses, below is how this would look in the code. The workflow will vary depending on if you're executing the code in-process or out-of-process.
# Option A : When you're executing code in-process #
# Use this line if you're not sure if it's already true
arcpy.env.addOutputsToMap = True
# Executing tool will automatically add layer to map
# Option B : When you're executing code out-of-process #
# Hook into the map document
mxd = arcpy.mapping.MapDocument(r"Path\To\MapDocument")
# Hook into the data frame where you want to add the layer
df = arcpy.mapping.ListDataFrames(mxd)
# Create a Layer object
lyr = arcpy.management.MakeFeatureLayer(r"Path\To\GDB\FeatureClass", "NameForLayer").getOutput(0)
# Add the layer object to the map
The arcpy function and class tree
Makefeaturelayer when you are using python with arcmap open and you have geoprocessing options set to add results to the display toggled on.
Now, that should be a start, but the process you are using will dictate other options.
Make Feature Layer—Help | ArcGIS for Desktop (Dan provided the Pro version)
Creates a feature layer from an input feature class or layer file. The layer that is created by the tool is temporary and will not persist after the session ends unless the layer is saved to disk or the map document is saved.....Layers created in ArcCatalog cannot be used in ArcMap unless they are saved to a layer file using the Save To Layer File tool.
Creates a feature layer from an input feature class or layer file. The layer that is created by the tool is temporary and will not persist after the session ends unless the layer is saved to disk or the map document is saved.
The help page includes some sample code.
MakeFeatureLayer is giving an error:
Input Features: Dataset ...\unified.gdb\feature21 does not exist or is not supported
1. Are you able to navigate to add this feature class manually in ArcMap?
2. If yes, could you show me the full path to the data?
Yes, it's in C:\Users\Marcel\Documents\ArcGIS\scratch\unified.gdb\feature21
unified.gdb looks like a folder from the outside, but when I open it, it has all these files with weird extensions (.gdbtable, .gdbindexes, .gdbtblx, etc.). I know, must be one of these two, file database or personal database, just don't know which one.
What do you get if you run the following command?
Apparently I wasn't using the "r", so it was giving me False at first. I was able to add the data, thanks.
Retrieving data ...