0

I literally copied and pasted the file path (r'C:\Users\myName\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\mydatabase.sde'), but after I run my script, I always get the error saying error 267, the directory name is invalid.

1
  • 1
    A .sde file is not a directory. It is a file. OS tools will not see it as an ArcGIS workspace, suitable for ListFeatureClasses
    – Vince
    Commented Jul 5, 2019 at 15:06

1 Answer 1

1

This works for me to access ArcSDE feature classes in feature datasets;

wrkspc = r"D:\Projects\DotNetDataLoader\Connection to xxx.xx.x.xxx.sde"
arcpy.env.workspace = wrkspc
listds = arcpy.ListDatasets("*"):
for ds in listds:
    listfc = arcpy.ListFeatureClasses("*","",feature_dataset=ds)
    for fc in listfc:
        print fc
3
  • 3
    If there are feature classes outside of datasets, then you also need a arcpy.ListFeatureClasses without a feature_dataset parameter. And tables without geometry would need arcpy.ListTables.
    – Vince
    Commented Jul 5, 2019 at 15:44
  • i think this is almost what i want, except it isn't working for me? If i only want to access sde tables, do i change the ListFeatureClasses to ListTables? Commented Jul 5, 2019 at 15:58
  • yes I think that would be best if they are non spatial tables. Commented Jul 5, 2019 at 15:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.