1

I am attempting to create a table with appropriate schema. I have created a data dictionary with the appropriate values stored in a list. See below

schema_dict = {"borough" : ["borough","TEXT","","",2,"borough","NON-NULLABLE"],
"block" : ["block","LONG",10,"","","block","NON-NULLABLE"],
"lot" : ["lot","SHORT",5,"","","lot","NON-NULLABLE"],
"cd" : ["cd","SHORT",5,"","","cd","NULLABLE"]}

Then I use this data dictionary to call the appropriate parameter value when looping through a list of my fields as such:

for item in schema_dict:
    arcpy.AddField_management(table_name, schema_dict[item][0],
                                          schema_dict[item][1],
                                          schema_dict[item][2],
                                          schema_dict[item][3],
                                          schema_dict[item][4],
                                          schema_dict[item][5],
                                          schema_dict[item][6])
    print("Converting to appropriate schema for field " + str(schema_dict[item[0]]))

For whatever reason I am receiving the following errors:

ExecuteError: ERROR 000622: Failed to execute (Add Field). Parameters are not valid.

ERROR 000800: The value is not a member of NULLABLE | NON_NULLABLE.

According to the examples provided in the add field management doc, a string of "NULLABLE" or "NON-NULLABLE" should be sufficient, no? I notice the type is Boolean, should I be giving the parameter a value of True or False rather than the strings I supplied?

  • 1
    integer fields are not nullable – jbalk Nov 2 '18 at 16:44
  • If you add a print line before passing this, what do you get? And when running the addfield_management, do any of the fields get added? – smiller Nov 2 '18 at 16:46
  • 1
    Appears to be an error in Esri's documentation / code sample in that case. – smiller Nov 2 '18 at 16:50
0

Apparently the documentation for AddField_management is incorrect? Using strings "NON-NULLABLE" and "NULLABLE" would throw the following errors

ExecuteError: ERROR 000622: Failed to execute (Add Field). Parameters are not valid.

ERROR 000800: The value is not a member of NULLABLE | NON_NULLABLE.

But switching all my "NULLABLE" values to True and "NON-NULLABLE" values to False (i.e. using Booleans instead of Strings) ultimately gave my output table/feature class the correct schema.

This is counter to the examples provided in the documentation and should be noted for anyone experiencing similar issues.

0

Your syntax is fine, the text is fine, but you cannot create a nullable integer field in arc when using SHAPEFILES

If you use the tools in arc, or the python window in arc, it will let you include the NULLABLE/NON-NULLABLE parameter but it will not honor it for integer or float fields in SHAPEFILES

EDIT:

I figured out why I could not null my newly created "nullable" fields. I was testing this on a shapefile. When using a shapefile, integer and float fields will not be nullable even when created with the nullable parameter set to True. However, it will create nullable float and integer fields in a file gdb.

I created the same field to a shapefile and a gdb using this code:

arcpy.AddField_management(fc,"test","SHORT","#","#","#","#",True)

Here is the result (SHP|GDB):

enter image description here enter image description here

  • What do you mean you can't make an INT field Nullable? I just did it in both the UI and through the AddField tool. – KHibma Nov 2 '18 at 19:00
  • Now try to null the field. Or just right click on the field and view it's properties. I guarantee that it is non-nullable. If you use the tools in arc, or the python window in arc, it will let you include the NULLABLE/NON-NULLABLE parameter but it will not honor it. – jbalk Nov 2 '18 at 19:05
  • This doesn't seem to be true. Adding boolean parameter values rather than strings gave me the appropriate output. See my answer above. – CambrianCatalyst Nov 2 '18 at 20:00
  • @CambrianCatalyst The code will execute, and the field will be added, but it WILL NOT BE NULLABLE. Test it. – jbalk Nov 2 '18 at 21:07
  • I have. The fields I marked as true came back nullable. The ones I marked false came back non-nullable. I'm creating the FC in a rather roundabout way, but it did work. I'll share the full code if you'd like to see it – CambrianCatalyst Nov 2 '18 at 23:47

Your Answer

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

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