Reputation: 1329
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.
Upvotes: 33
Views: 11940
Reputation: 581
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.
Upvotes: 0
Reputation: 169284
dev_appserver.py --clear_datastore=yes myapp
See here for more info.
Shorthand version:
dev_appserver.py -c
Upvotes: 31
Reputation: 1366
dev_appserver.py [app directory] --clear_datastore true
you need to shutdown the server if its running at the time to free the ports
Upvotes: 4
Reputation: 18573
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.
Upvotes: 20
Reputation: 1172
In production - you can go to appengine dashboard => Datastore admin
Upvotes: 0
Reputation: 5249
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('.')
Upvotes: -1
Reputation: 920
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)
Upvotes: 2