I am wanting to create a version, step into the version, make edits, and then post and reconcile that version. When I get to the ReconcileVersions_management tool, it is giving me

ERROR 000301: The workspace is of the wrong type

I think that might mean "the version is locked for editing" or "the connection to the db is still open--we can't operate on it". I'm posting my long-ish code, looking for answers.

import arcpy
import os
from datetime import datetime

# make a connection to SDE.DEFAULT
    filename1 = "fn1"
    foldername1 = os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog")
    servername1 = "gissvc"
    servicename1 = "sde:oracle11g:GISDEVR"
    dbname1 = ""
    auth1 = ""
    un1 = "MyUser"
    pass1 = "MyPass"
    userinfo1 = ""
    ver1 = "SDE.DEFAULT"
    sv1 = "SAVE_VERSION"

    if os.path.isfile(os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog", filename1 + ".sde")):
        os.remove(os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog", filename1 + ".sde"))
    print "creating connection to " + ver1    
    arcpy.CreateArcSDEConnectionFile_management(foldername1, filename1, servername1,
                                                    servicename1, dbname1, auth1,
                                                    un1, pass1,  userinfo1, ver1, sv1)
    ws1 = os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog", filename1 + ".sde")
    ver2 = "net_edits"

# create a version

    for version in arcpy.da.ListVersions(ws1):
        if ver2 in version.name:
            print ver2 + " exists, deleting"
            arcpy.DeleteVersion_management(ws1, version.name)  
    print "creating new version, " + ver2
    arcpy.CreateVersion_management(ws1, "SDE.DEFAULT", ver2, "PUBLIC")

# connect to new version

    filename2 = "fn2"
    foldername2 = os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog")
    servername2 = "gissvc"
    servicename2 = "sde:oracle11g:GISDEVR"
    dbname2 = ""
    auth2 = ""
    un2 = "MyUser"
    pass2 = "MyPass"
    userinfo2 = ""
    #ver2 = "net_edits"
    sv2 = "SAVE_VERSION"

    if os.path.isfile(os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog", filename2 + ".sde")):
        os.remove(os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog", filename2 + ".sde"))
    print "creating connection to " + ver2    
    arcpy.CreateArcSDEConnectionFile_management(foldername2, filename2, servername2,
                                                    servicename2, dbname2, auth2,
                                                    un2, pass2,  userinfo2, ver2, sv2)
    ws2 = os.path.join(os.environ['APPDATA'],"ESRI","Desktop10.2","ArcCatalog", filename2 + ".sde")

# edit some things -- select where status = 5, change to "tacos"

    tbl_vw = "t"
    where = 'STATUS = 5'
    arcpy.MakeTableView_management(os.path.join(ws2, "fooditems"), tbl_vw, where, "", "")
    arcpy.CalculateField_management(tbl_vw, "STATUS", '"tacos"')

# close connections

    print arcpy.GetMessages()

# reconcile with post

    reclogname = "reconcile_log_" + str(datetime.now().strftime('%Y-%m-%d')) + ".txt"
    reclog = os.path.join("F:\PythonScripts","ErrorLogFiles",reclogname)
    if os.path.isfile(reclog):
    print "reconciling with post and delete_version options set"
    arcpy.ReconcileVersions_management(ws2, "ALL_VERSIONS", "SDE.Default", ver2,
                                   "LOCK_ACQUIRED", "ABORT_CONFLICTS", "BY_OBJECT",
                                   "FAVOR_TARGET_VERSION", "POST", "DELETE_VERSION", reclog)
except Exception as e:
    print e.message

2 Answers 2


I had this same issue-- spent time troubleshooting the operation in ArcMap (where it was successful), then copying the python snippet from the Results pane and comparing to my code.

End result: when referring to the default version in arcpy.ReconcileVersions_management, it must be sde.DEFAULT, not SDE.Default. I had this as well, took me a long time to figure it out.


I fixed this error by changing the connection type to 'dbo.DEFAULT'. This was successful because my connection file was made with a user with a dbo role in SQL (even though the sde connection authentication is OS).

How To: Automate reconcile, post and compress processes

DBO or SDE or what Schema?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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