How do we define SDE Connection for workspace in Python Scripting?
Answer
D.E.Wright just beat me to it, he's right on, use a connection just like in ArcCatalog. But here's my take, done at the Python prompt in ArcMap, using the direct full path to a sde connection file:
>>> import arcpy
>>> arcpy.env.workspace = "C:\\Users\\chad\\AppData\\Roaming\\ESRI\\Desktop10.0\\ArcCatalog\\anrc_water (anrcuser).sde"
>>> fdlist = arcpy.ListDatasets()
>>> for fd in fdlist:
... print fd
...
anrc_water.DBO.ChadTest
anrc_water.DBO.Temp_Data
anrc_water.DBO.Master_Datasets
ANRC_WATER.DBO.ENF_FILL_FACC
ANRC_WATER.DBO.ENF_FILL_FDIR
>>>
To get the path to my sde connection file, I just right-clicked on my SDE database in the Catalog tree, went to properties, then on the General tab, copy the path from the Name field:
No comments:
Post a Comment