How to delete all datastore in Google App Engine?

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

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

相关标签:
29条回答
  • 2020-11-28 01:48

    If you have a lot of data, using the web interface could be time consuming. The App Engine Launcher utility lets you delete everything in one go with the 'Clear datastore on launch' checkbox. This utility is now available for both Windows and Mac (Python framework).

    0 讨论(0)
  • 2020-11-28 01:49

    You can Delete All Datastore by deleting all Kinds One by One. with google appengine dash board. Please follow these Steps.

    1. Login to https://console.cloud.google.com/datastore/settings
    2. Click Open Datastore Admin. (Enable it if not enabled.)
    3. Select all Entities and press delete.(This Step run a map reduce job for deleting all selected Kinds.)

    for more information see This image http://storage.googleapis.com/bnifsc/Screenshot%20from%202015-01-31%2023%3A58%3A41.png

    0 讨论(0)
  • 2020-11-28 01:49

    Here's how I did this naively from a vanilla Google Cloud Shell (no GAE) with python3:

    from google.cloud import datastore
    client = datastore.Client()
    query.keys_only()
    for counter, entity in enumerate(query.fetch()):
        if entity.kind.startswith('_'):  # skip reserved kinds
            continue
        print(f"{counter}: {entity.key}")
        client.delete(entity.key)
    

    This takes a very long time even with a relatively small amount of keys but it works.

    More info about the Python client library: https://googleapis.dev/python/datastore/latest/client.html

    0 讨论(0)
  • 2020-11-28 01:50

    I've created an add-in panel that can be used with your deployed App Engine apps. It lists the kinds that are present in the datastore in a dropdown, and you can click a button to schedule "tasks" that delete all entities of a specific kind or simply everything. You can download it here:
    http://code.google.com/p/jobfeed/wiki/Nuke

    0 讨论(0)
  • 2020-11-28 01:50

    For java

    DatastoreService db = DatastoreServiceFactory.getDatastoreService();
    List<Key> keys = new ArrayList<Key>();
    for(Entity e : db.prepare(new Query().setKeysOnly()).asIterable())
        keys.add(e.getKey());
    db.delete(keys);
    

    Works well in Development Server

    0 讨论(0)
  • 2020-11-28 01:51

    For Python, 1.3.8 includes an experimental admin built-in for this. They say: "enable the following builtin in your app.yaml file:"

    builtins:
    - datastore_admin: on
    

    "Datastore delete is currently available only with the Python runtime. Java applications, however, can still take advantage of this feature by creating a non-default Python application version that enables Datastore Admin in the app.yaml. Native support for Java will be included in an upcoming release."

    0 讨论(0)
提交回复
热议问题