views:

28

answers:

2

I am trying to delete records in the datastore. Unfortunately, whenever I try to delete the items, it gives me a BadValueError, saying Districts (one of the columns) is required. Because of an issue with the bulk loader, Districts is null for all of the rows...but I still need to clean out the datastore to try to fix the bulk loader error.

What can I do?

A: 

Change your entities/models so that Districts is no longer a required property?

matt b
+3  A: 

Try updating your model so that the Districts field is not required (i.e., pass required=False as a keyword parameter to the Districts field). Then the validator shouldn't complain about the existing entities and you should be able to delete the entities.

Alternatively, if you know the keys for the entities you want to delete, you can delete them directly using db.delete() without ever needing to fetch them in the first place.

You might even be able to use the datastore viewer from the Dashboard to delete them (if you don't have many entities to delete, this might be easiest).

David Underhill
Thanks for the answer. I ended up doing it manually. I believe Districts was required because it was a "list" item. How do you "update" the model? I thought it was declared when you saved the entity. Since the appengine app pulls the model code each time, does that "update" it?
etc
Great, I'm glad it worked out. You're right that list properties on (static) models must be `required=True`. As for how to "update" the model: The model can be updated by simply changing the code for the appropriate class. The reason this works is because the GAE datastore is schema-less - the definition of your model is used to interpret the bytes which are stored in the datastore.
David Underhill
Thus changing your model definition simply changes how the bytes are interpreted when you app retrieves them from the datastore. (note: sorry, my comment got split in two)
David Underhill