1

I used python add in to make a tool bar in Arcmap that edits features on a map. It works on a file geodatabase, but not on an ArcSDE version one. I've been getting an FDO error: 0. The solutions that I've found all involve opening a workspace, but I'm getting an error doing that as well. Here is the relevant portion of my code:

        outFolderPath = r"U:\tempStuff"
        outName = "Stuff.sde"
        databasePlatform = "SQL_Server"
        instance = "SQL Server"
        arcpy.CreateDatabaseConnection_management(outFolderPath, outName,
                                                  databasePlatform,
                                                  instance)
        print "Centroid of buidling:(%r,%r) Side length: %r" % (xCoordinate,
                                                                yCoordinate,
                                                                bob)
        print "workspace is %r" % outName #outName is workspace

        #Start edit session with an undo/redo stack then start
        #edit operation
        print "Starting editing"
        edit = arcpy.da.Editor(outName) #outName is workspace Line 86
        edit.startEditing(True, True)
        edit.startOperation()

        #stuff happens

        cursor = arcpy.da.InsertCursor( fc, ["SHAPE@"])
        cursor.insertRow([stuff])
            #stop the edit operation and then save changes
        edit.stopOperation()
        edit.stopEditing(True)

        del cursor
        print "Building should be drawn"

This is the exact error I've been getting:

Traceback (most recent call last):
  File "C:\Users\153289\AppData\Local\ESRI\Desktop10.3\AssemblyCache\{0BEF4E61-6332-4BCA-A908-959CA3C0B4E7}\leetScripts_addin.py", line 86, in onClick
    edit = arcpy.da.Editor(outName)#outName is workspace
RuntimeError: cannot open workspace

What's am I doing wrong in my code?

  • Maybe outName needs to be a full path? – Hornbydd May 26 '16 at 21:53
  • 1
    The instance value is wrong. Use 'hostname' or 'hostname\nonDefaultService'. You can also use createdConn = arcpy.CreateDatabaseConnection_management(... to obtain the full path – Vince May 26 '16 at 22:07
  • I can't tell you the hostname of your server. – Vince May 26 '16 at 22:10
  • @Vince ah. My mistake I didn't see that variable and thought you were talking about how I called stuff. Do you know how to find out what the host name of my server is using Arc? – user66821 May 26 '16 at 22:13
  • 2
    If you are getting a new error I think it is best to research/ask about it as a new question rather than in a single one that will "strand" any answers to your original question. – PolyGeo May 26 '16 at 22:50
2

Looks like you are not referencing the full path to your newly created SDE connection. Try this:

edit = arcpy.da.Editor(os.path.join(outFolderPath, outName))
  • Just tried that. Same error message. – user66821 May 26 '16 at 22:06
  • It's working for me now. No idea why lol – user125266 Aug 23 '18 at 17:15
0

I think arcpy.da.Editor requires an arcpy environment workspace (arcpy.env.workspace) to be set.

This is what I've got in one of my Editing python scripts

arcpy.env.workspace = os.path.join(outFolderPath, outName)

edit = arcpy.da.Editor(arcpy.env.workspace) 
edit.startEditing(True, True)
edit.startOperation()
  • That returns the original error. – user66821 May 27 '16 at 21:49
0

I got the similar error. The same script worked in one environment (10.4.1) but not failed in another (10.6.1). I simply added import os, and the script came back to life.

Your Answer

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