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.

closed as off-topic by PolyGeo Jul 5 at 21:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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 Jul 5 at 15:06

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
    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 Jul 5 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? – GISProdigy Jul 5 at 15:58
  • yes I think that would be best if they are non spatial tables. – Gary Lester Jul 5 at 15:59

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