Google App Engine的remote_api:删除django nonrel中的所有数据

发布于 2024-09-06 18:10:10 字数 1095 浏览 7 评论 0 原文

我正在使用 django non-rel (http://www.allbuttonspressed.com/projects/django -nonrel)并尝试删除我的产品数据存储中的所有数据。我正在阅读此处提出的问题 如何删除 Google 中的所有数据存储区App Engine?但答案对我不起作用。

这是因为我做得不正确还是因为我们使用的是 django,其中层在将数据保存到数据存储之前对数据进行操作?

澄清一下,这些是我删除所有数据存储数据所采取的步骤。

  1. 我转到了程序文件中的 google app engine 文件夹

  2. 在命令行中输入了“remote_shell_api.py yourapp /remote_api”

  3. 当我成功登录时,我尝试导入我的一个应用程序文件夹,但它不允许我导入它,更不用说删除它了。

  4. 当然,输入我的项目的等效项也失败了

from models import Entry  
query = Entry.all()    
entries =query.fetch(1000)    
db.delete(entries)

我还考虑执行此处的步骤(http://code.google.com/appengine/docs/python/tools/uploadingdata.html)但是我真的很困惑。有人可以澄清一下过程吗?它与普通的谷歌应用程序引擎项目不同吗?如果有,我们如何使用它?

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.

  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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

灰色世界里的红玫瑰 2024-09-13 18:10:10

这里有两个问题:

  1. 为了导入包和模块,它们需要位于 PYTHONPATH 上。为此,请运行设置了 PYTHONPATH 变量的 shell:PYTHONPATH=path_to_your_app remote_api_shell.py yourapp
  2. App Engine 的各种 Django 补丁会修改数据存储模型类,以将种类名称更改为完全限定的 - 例如,模块“bar”中定义的模型“Foo”在 Django 中将是“bar_Foo”,而 App Engine 本身则为“bar_Foo”只是称其为“Foo”。为了应用此补丁,您需要确保已导入 Django 补丁的适当部分以允许其应用此猴子补丁。

与此相关的是,如果您有大量数据,您可能需要使用新的 mapreduce相反,它完全在服务器上运行并且速度更快。

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.

注定孤独终老 2024-09-13 18:10:10

您尝试过以下方法吗?

Entry.objects.all().delete()

Entry 是您的 Django 模型。

Have you tried the following?

Entry.objects.all().delete()

Entry being your Django model.

红ご颜醉 2024-09-13 18:10:10

事实证明,django non-rel 使用自己的远程 shell。因此,

manage.py 远程 shell

将带您进入应用程序引擎,您可以在其中删除正确映射到应用程序引擎数据存储区的数据。感谢大家的帮助!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文