Setting workspace to SDE feature dataset

2079
4
Jump to solution
03-12-2013 06:10 AM
KerryAlley
Occasional Contributor
I have a python add-in that successfully edits data in a file .gdb (with or without invoking the editor in the script), but I can't edit data in an SDE feature dataset.  I can edit the SDE data (9.3) manually in ArcMap, and the add-in successfully interacts with the SDE data using search cursors.  SP1 is installed.  Any suggestions about what might be causing the error in response to this code?

workspace = r"Database Connections\GDB_HMSDEV.sde\GDB_HMSDEV.HMSADMIN.KerrySandbox" edit = arcpy.da.Editor(workspace)


Traceback (most recent call last):
  File "C:\Users\kalley\AppData\Local\ESRI\Desktop10.1\AssemblyCache\{87D25F75-9A62-5BC9-A006-4B496936EC0F}\ShieldToolTest_addin.py", line 79, in onLine
    edit = arcpy.da.Editor(workspace)
RuntimeError: cannot open workspace

I can provide the full code if necessary...just wanted to keep it simple first.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MichaelVolz
Esteemed Contributor
Kerry:

Since you are using ArcGIS v10.1 you might need to specify the full path to the SDE connection and just

r"Database Connections\GDB_HMSDEV.sde\GDB_HMSDEV.HMSADMIN.KerrySandbox"

View solution in original post

0 Kudos
4 Replies
MichaelVolz
Esteemed Contributor
Kerry:

Since you are using ArcGIS v10.1 you might need to specify the full path to the SDE connection and just

r"Database Connections\GDB_HMSDEV.sde\GDB_HMSDEV.HMSADMIN.KerrySandbox"
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Kerry,

You won't be able to set the workspace to a feature dataset.  It will need to be set only to the sde geodatabase.  When you specify a feature class within the feature dataset, just add the feature dataset name first.  Ex:

env.workspace = r"Database Connections\SQLSERVER.sde"
desc = arcpy.Describe("Structures\Bridges")
0 Kudos
KerryAlley
Occasional Contributor
Thanks mvolz47! 

What you said finally sank into my thick head... and set off a whole cascade of Eureka moments. 
I simply changed the workspace (using the .workspacePath of a layer instead of its .dataSource):
workspace = rdsmall_lyr.workspacePath

which was equivalent to the SDE connection path:
workspace = r"C:\Users\kalley\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\GDB_HMSDEV.sde"

and everything went smoothly!

Thanks again!!
0 Kudos
DanNguyen
New Contributor

If my GIS session is through a Citrix connection, do you know what would be my database connection? I can't seem to get my script to start Edit session.

Any helps will be greatly appreciated.

Thanks

0 Kudos