views:

52

answers:

3

I'm using django non-rel (http://www.allbuttonspressed.com/projects/django-nonrel) and am trying to delete all the data in my production's datastore. I was reading the question posed here http://stackoverflow.com/questions/1062540/how-to-delete-all-datastore-in-google-app-engine but the answer wasn't working for me.

Is this because I'm not doing it correctly or because we are using a django where the layers manipulate the data before being saved onto datastore?

Just to clarify, these are the steps I've taken to delete all datastore data.

1) I went to google app engine's folder in program files

2) In command line, entered "remote_shell_api.py yourapp /remote_api"

3) when I got in successfully, I tried to import one of my app folders but it wouldn't allow me to import it, let alone delete it.

4) Of course, typing my project's equivalent of this also failed

from models import Entry

query = Entry.all()

entries =query.fetch(1000)

db.delete(entries)

I also looked into doing the steps in here (http://code.google.com/appengine/docs/python/tools/uploadingdata.html) but I got really confused. Can anybody clarify the process? Is it different than the normal google app engine projects, if so, how do we use it?

A: 

There's two issues at work here:

  1. In order to import your packages and modules, they need to be on the PYTHONPATH. To do so, run the shell with the PYTHONPATH variable set: PYTHONPATH=path_to_your_app remote_api_shell.py yourapp.
  2. The various Django patches for App Engine modify the datastore Model class to change the kind name to be fully-qualified - eg, a model "Foo" defined in module "bar" will be "bar_Foo" in Django, while App Engine on its own just calls it "Foo". In order for this patch to be applied, you need to make sure you have imported the appropriate parts of the Django patch to allow it to apply this monkeypatch.

On a related note, if you have a lot of data, you may want to use the new mapreduce library instead, which runs entirely on the server and will be much faster.

Nick Johnson
A: 

Have you tried the following?

Entry.objects.all().delete()

Entry being your Django model.

Claude Vedovini
A: 

As it turns out, django non-rel uses its own remote shell. So

manage.py remote shell

will take you into app engine where you can delete your data that is properly mapped into app engine's datastore. Thanks for all the help guys!