2

I am trying to get list of datasets within sde connection.This sde connection is already present in ArcMap and all datasets are visible. I am posting snapshot my code. It is returning empty array,though there are clearly many datasets available. What is the problem with my code? enter image description here

import arcpy

arcpy.env.workspace = "C:\Users\Vijay\AppData\Roaming\ESRI\Desktop10.5\ArcCatalog\xxx.sde"
featureDatasets = arcpy.ListDatasets()
print featureDatasets
for fc in featureDatasets:
    try:
        print fc
    except Exception as e:
        print e
  • 3
    Add the code as text instead of a screenshot. What are you trying to list? For example ListDatasets will not list Feature Classes. Try adding an r in front of the path, r"C:\...." – BERA Mar 28 at 6:27
  • 2
    Datasets or feature classes? What does it look like in ArcCatalog (ok to screen shot that and paste into your question). How are you running this? From catalog, IDLE, CMD, ArcMap? Is your username and password saved in that connection file? – Michael Stimson Mar 28 at 6:32
  • 1
    I want list of feature datasets only.Feature classes are within datasets.And adding r at front of path, r"C:\..." is still giving empty array. – Mansi Mar 28 at 6:34
  • 1
    Works just fine for me, either your credentials aren't stored in your connection file or the connecting user lacks permissions to view the datasets.. of course it could be that you're executing from the IDLE shell which is known to be a bit flaky, try it from the python window of ArcCatalog or ArcMap and see if that works. – Michael Stimson Mar 28 at 6:40
  • 1
    It does print the array of datasets. That array is empty. You should focus on whether os.path.exists(arcpy.env.workspace) returns True. – Vince Mar 28 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.