How to delete all datastore in Google App Engine?

后端 未结 29 1882
夕颜
夕颜 2020-11-28 01:17

Does anyone know how to delete all datastore in Google App Engine?

29条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 01:46

    The best approach is the remote API method as suggested by Nick, he's an App Engine engineer from Google, so trust him.

    It's not that difficult to do, and the latest 1.2.5 SDK provides the remote_shell_api.py out of the shelf. So go to download the new SDK. Then follow the steps:

    • connect remote server in your commandline: remote_shell_api.py yourapp /remote_api The shell will ask for your login info, and if authorized, will make a Python shell for you. You need setup url handler for /remote_api in your app.yaml

    • fetch the entities you'd like to delete, the code looks something like:

        from models import Entry
        query = Entry.all(keys_only=True)
        entries =query.fetch(1000)
        db.delete(entries)
        \# This could bulk delete 1000 entities a time
    

    Update 2013-10-28:

    • remote_shell_api.py has been replaced by remote_api_shell.py, and you should connect with remote_api_shell.py -s your_app_id.appspot.com, according to the documentation.

    • There is a new experimental feature Datastore Admin, after enabling it in app settings, you can bulk delete as well as backup your datastore through the web ui.

提交回复
热议问题