33

How can I remove all entities or reset the local datastore on my dev_appserver? I accidentally recursively called a function to create an entity when testing.

I am using the Google App-engine SDK on Vista with Python.

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
Jason Rikard
  • 1,329
  • 1
  • 14
  • 23

7 Answers7

31
dev_appserver.py --clear_datastore=yes myapp

See here for more info.

Shorthand version:

dev_appserver.py -c
Hoang Pham
  • 6,899
  • 11
  • 57
  • 70
mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
  • Wow, looked over that for sure. Thank you – Jason Rikard Jun 18 '09 at 03:08
  • If you are using the App Engine Launcher, you can do the same by putting the flags in "Extra Command Line Flags" field by going to Edit > Application Settings – jesal Aug 23 '12 at 22:06
  • this seems to be outdated or something... i get errors trying to use it – Or Gal Dec 20 '13 at 08:56
  • 6
    that didnt work but this did dev_appserver.py [app directory] --clear_datastore true – Or Gal Dec 20 '13 at 09:02
  • Any insight as to why this works, while deleting the entire "target" directory doesn't? Where exactly is the datastore being stored? – dzimney Dec 16 '17 at 17:21
20

If you came here for a Java solution: Delete the following file:

{project root}/WEB-INF/appengine-generated/local_db.bin

Rebuild and restart your project.

Nilzor
  • 18,082
  • 22
  • 100
  • 167
  • Can't find this directory in the project – serj Oct 14 '15 at 07:39
  • I have found such file in `out/artifacts/xxxx_war_exploded/WEB-INF/appengine-generated`, the file seems surprisingly small, though - it is probably only some kind of index, real data (blobs?) are probably stored someplace else. I had to restart the server to complete the deletion. – Suma Apr 28 '17 at 19:47
4

dev_appserver.py [app directory] --clear_datastore true

you need to shutdown the server if its running at the time to free the ports

Or Gal
  • 1,298
  • 3
  • 12
  • 20
2

A useful thing to do is to always specify --datastore_path, e.g. --datastore_path=test.datastore.

To delete it you can then just delete the file. You can also keep copies and swap them in and out. And the store will persist over reboots (when /tmp/ the default location for it on Linux anyway, gets cleared)

frabcus
  • 919
  • 1
  • 7
  • 18
0

Here is my output after running dev_appserver

INFO     2017-03-21 15:07:36,085 devappserver2.py:764] Skipping SDK update check.
INFO     2017-03-21 15:07:38,342 api_server.py:268] Starting API server at: http://localhost:63970
INFO     2017-03-21 15:07:38,349 dispatcher.py:199] Starting module "default" running at: http://localhost:8080
INFO     2017-03-21 15:07:38,373 admin_server.py:116] Starting admin server at:

So I go to http://localhost:8000 and I am able to go to my local App Engine Admin Console and edit/delete datastore entities.

Nathan Fowler
  • 561
  • 5
  • 19
0

In production - you can go to appengine dashboard => Datastore admin

ronme
  • 1,154
  • 1
  • 11
  • 18
-1

in production, this may also come in handy (or be a security nightmare).

# will DELETE the database use http://localhost:8083/deletemodels?force=true
class DeleteModels(webapp.RequestHandler):
    def get(self):

    def dMsg(msg):
      self.response.out.write(msg + '\n')
    n = self.request.get('force')
    if n:
      dMsg('clearing YourModelHere data....')
      for uc in YourModelHere.all():
               uc.delete()
               dMsg('.')
      dMsg('clearing YouNextModelHere data....')           
      for uc in YouNextModelHere.all():
               uc.delete()
               dMsg('.')     
johndpope
  • 5,035
  • 2
  • 41
  • 43