Select to view content in your preferred language

Error in Creation of multiple objects in an Enterprise Geodatabase

438
1
09-29-2022 10:38 PM
Cristian_Galindo
Occasional Contributor III

1. Create a Enterprise geodatabase

2. Run the following code:

 

 

import arcpy

arcpy.env.workspace = r"C:\temp2\DataOwner.sde"
# arcpy.env.autoCommit = 5

for i in range(0, 100):
    arcpy.management.CreateDomain(arcpy.env.workspace, f"CG_Domain_{i}", f"CG_Domain_{i}", "TEXT", "CODED")
    print(f"CG_Domain_{i}")
    for j in range(0, 100):
        arcpy.management.AddCodedValueToDomain(arcpy.env.workspace, f"CG_Domain_{i}", f"CG_Domain_Code_{j}", f"CG_Domain_Code_{j}")
        print(f"    CG_Domain_Code_{j}")

 

 

3. the script never ends successfully, always in some point it crash

 

 

CG_Domain_0
CG_Domain_Code_0
CG_Domain_Code_1
CG_Domain_Code_2
CG_Domain_Code_3
CG_Domain_Code_4
Traceback (most recent call last):
File "C:/Users/svc_distripoint_nima/.PyCharmCE2019.1/config/scratches/scratch_1.py", line 10, in <module>
arcpy.management.AddCodedValueToDomain(arcpy.env.workspace, f"CG_Domain_{i}", f"CG_Domain_Code_{j}", f"CG_Domain_Code_{j}")
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 2652, in AddCodedValueToDomain
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 2649, in AddCodedValueToDomain
retval = convertArcObjectToPythonObject(gp.AddCodedValueToDomain_management(*gp_fixargs((in_workspace, domain_name, code, code_description), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 000535: Workspace does not exist.
Failed to execute (AddCodedValueToDomain).

 

 

 

Some of the domains were created, but it keep returning error,

 

I want to check if this is related with the database, i can run a profiler (SQL Server profiler), but the databases are not my strongest skill. What should i look in that profiler, I mean which counters should i set ?

Is there a known reason for this behavior?

[EDIT 1]:  following the documentation I decided to use the following 2 statements right after import of the arcpy module:

 

arcpy.env.autoCommit = 100
arcpy.SetLogHistory(False)

 

 

The result is the same.

0 Kudos
1 Reply
RichRuh
Esri Regular Contributor

You'll probably get more responses if you move this to the ArcGIS Python forums. This is for C#