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 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.
I went to google app engine's folder in program files
In command line, entered "remote_shell_api.py yourapp /remote_api"
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.
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 开发者_如何学Cprojects, if so, how do we use it?
There's two issues at work here:
- 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
. - 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.
Have you tried the following?
Entry.objects.all().delete()
Entry
being your Django model.
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!
精彩评论