0

I have an arcpy-script which I want to execute outside ArcGIS which sould open an SDE-workspace. Therefor I create a new SDE-file by using arcpy.CreateArcSDEConnectionFile_management. When I use that file within ArcCatalog I can establish the connection to my database, however when I use it in my script I cannot access the actual workspace:

# create the SDE-file and connect to the workspace
sdeFileName = user  + "@" + server + ".sde"
arcpy.CreateArcSDEConnectionFile_management(temp, sdeFileName, server, service, username = user, password = password, version = version)    
arcpy.env.workspace = temp + os.sep + sdeFileName

Now when iterating the datasets within the workspace I get an empty array:

datasets = arcpy.ListDatasets()

Whereas the SDE DOES have lots of featureDatasets and other tables.

I use PyScripter and when I hover the env-or arcpy it shows me where those names are defined. However the same does not apply to the workspace making me wonder if I have to import or load another module where the member is defined.

Do you have any suggestions on how to open that workspace? The lines above are more ore less taken from example 4 on ArcGIS Help-site

EDIT: I tried out using an arbitrary (non-existing) SDE-file. Thus I got an exception on ListDatasets saying I cannot iterate a NoneType. So I think my problem is not caused by workspace not being defined and therefor any module not being loaded as the mentioned method actually DOES return anything, at least an empty array instead of NoneType.

  • 2
    verify that the arcsde connection file does get created on disk and explore its properties with ArcMap. Then create a variable specifying the full path to the file on disk and set the arcpy.env.workspace. In other words, try to split your workflow into smaller parts and make sure they work as expected. – Alex Tereshenkov Oct 1 '15 at 9:58
-1

I´m not sure if this actually is the solution of the problem, however its a worksaround: when using an ApplicationServer-connection rather than a DiretConnect it works. However I doubt that this is the actual problem, I guess it has something to do with network-issues.

  • This isn't a long-term workaround -- Application services are deprecated at 10.2 and aren't available at ArcGIS 10.3. – Vince Oct 1 '15 at 11:00
  • This will absolutely be enough as the tool is designed for ArcGIS10 only for one-time schema-update. But usually you´re right that using ApplicationServer-connection should not be used any more. – HimBromBeere Oct 1 '15 at 11:06

Your Answer

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

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