Select to view content in your preferred language

JSONtoFeature File gdb vs SDE Geodatabase

1702
11
Jump to solution
08-09-2022 08:26 AM
jaykapalczynski
Honored Contributor

I have been successful in writing to a File Geodatabase using JSONtoFeature in python

But now I am trying to write to an Enterprise GDB and having issues.

I added the Connection File that has Admin Rights for this test.  So should be good to go there.

 

Thoughts?

 

Noting that just before this I am trying to DELETE the existing FC using this

fc_Delete = ["Data_Staging"]
for fc in fc_Delete:
   fc_path = os.path.join(cws, fc)
   if arcpy.Exists(fc_path):
      arcpy.Delete_management(fc_path)

 

FILE GEODATABASE - this works

dataOutput = r"C:/Users/t/Desktop/JSONSamples/INPUTJSONFILE.json"
output_fc = r'C:\\Users\\t\\Desktop\\JSONSamples\\outgdb.gdb\test'
arcpy.JSONToFeatures_conversion(dataInput, output_fc)

 

ENTERPRISE GEODATABASE - not working

dataInput = r"E:/ArcGIS_Server/ArcGIS/Trail/INPUTJSONFILE.json"
output_fc = r"E:/ArcGIS_Server/ArcGIS/Trail/ConnectionFile.sde/Data_Staging"
arcpy.JSONToFeatures_conversion(dataInput, output_fc)

 

ERROR:

Traceback (most recent call last):
File "E:\ArcGIS_Server_aws\ArcGIS_Published_MXDs\BirdingTrail\AddPoints_w_changeFieldTypes3.py", line 395, in <module>
main()
File "E:\ArcGIS_Server_aws\ArcGIS_Published_MXDs\BirdingTrail\AddPoints_w_changeFieldTypes3.py", line 43, in main
deleteExistingFC()
File "E:\ArcGIS_Server_aws\ArcGIS_Published_MXDs\BirdingTrail\AddPoints_w_changeFieldTypes3.py", line 137, in deleteExistingFC
arcpy.JSONToFeatures_conversion(dataInput, output_fc)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 1171, in JSONToFeatures
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 1168, in JSONToFeatures
retval = convertArcObjectToPythonObject(gp.JSONToFeatures_conversion(*gp_fixargs((in_json_file, out_features, geometry_type), 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 000206: Cannot create FeatureClass 'E:/ArcGIS_Server/ArcGIS/Trail/ConnectionFile.sde/Data_Staging'. Underlying DBMS error [[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Violation of PRIMARY KEY constraint 'R23_pk'. Cannot insert duplicate key in object 'dbo.Data_Staging'. The duplicate key value is (0).] [Trail.DBO.Data_Staging]
Failed to execute (JSONToFeatures).

0 Kudos
11 Replies
Brian_Wilson
Honored Contributor

So they have suggested the same hack I did, and they've known about the bug for 7 years.

jaykapalczynski
Honored Contributor

OK that makes me happy that it was not me but annoyed this is a 7 year bug

OK so I think I should be able to:

  1. Delete Features from my Enterprise GDB FC
  2. Read my file geodatabase FC
  3. Append it to the Enterprise Geodatabase FC

Work around but think it will work