11

I've been using App Engine with Python for a few months. Now that my application has a fair amount of code, I'm trying to solve a problem I've ignored so far:

Each time I turn off my computer, all my development datastore entities are removed.

I would like to keep this data until the next time I launch my development server. But I would also like to be able to turn off my computer without losing all of this data.

How should I proceed?

Thanks a lot

======== UPDATE ==========

When I set the datastore_path flag as explained by @moishe, my development server crashes as soon as it must write into the datastore.

File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore_file_stub.py", line 557, in __WritePickled
os.rename(tmp_filename, filename)
OSError: [Errno 13] Permission denied

Therefore, I gave this folder all UNIX permissions

chmod a+w /my_app_folder

But I have now another error which is

OSError: [Errno 21] Is a directory

Obviously the path should not be a directory. So I changed the path to:

/my_app_folder/data.datastore

And now it works! PFF...

alex
  • 479,566
  • 201
  • 878
  • 984
Damien
  • 439
  • 5
  • 16

4 Answers4

6

Maybe the default data store path is in a /tmp directory that's being deleted on shutdown? You can manually set the path with the --datastore_path flag in dev_appserver.py. See the docs for details.

Moishe Lettvin
  • 8,462
  • 1
  • 26
  • 40
  • Thanks for the link. I had looked through the docs and never came upon this article. Now I know what I'll do next time I launch my development server. Thanks! – Damien Nov 04 '11 at 08:19
  • Unfortunately my development server crashes when I try to write into the datastore when I set the --datastore_path flag. I put the traceback in my main question as an update... – Damien Nov 05 '11 at 10:13
3

flag when starting the dev server:

--storage_path=...

Path at which all local files (such as the Datastore, Blobstore files, Google Cloud Storage Files, logs, etc) will be stored, unless overridden by --datastore_path, --blobstore_path, --logs_path, etc.

found at https://developers.google.com/appengine/docs/python/tools/devserver?csw=1

mrauto
  • 91
  • 1
  • 7
  • note the confusion with --datastore_path which is referenced by many and that should be used only to override the correct flag --storage_path= One explanation why everybody seems to be missing --storage_path is that it's NOT listed in the --help of the dev-server as opposed to the other one... – mrauto Nov 18 '13 at 21:52
3

This clearing should not be the default behavior.

  1. Check that this application in the Google AppEngine launcher doesn't have the --clear_datastore flag.
    • Select app in list and select Edit->Applications Settings...
    • Extra Command Line Flags should be empty.

I once set this to restart some tests and forgot to remove it.

  1. Remove the existing application in the launcher and Create New Application. See if that helps.

  2. Verify the OS isn't deleted the file. If you open the log for the app, then launch it, the output says where the sqlite file is being located (e.g. T:\temp\dev_appserver.rdbms)

TrophyGeek
  • 5,902
  • 2
  • 36
  • 33
  • Thanks for the response. Actually I'm not using the Google App Engine launcher but my terminal. Do you know where I could change these settings? Thanks a lot. – Damien Nov 03 '11 at 15:55
  • The "setting" is just a flag passed to dev_appserver. – Moishe Lettvin Nov 03 '11 at 22:09
  • 3
    The datastore is stored in the OS's temporary directory by default; most OSes clear this on boot. – Nick Johnson Nov 04 '11 at 07:35
  • Ok on my MAC it looks like it's directly under ~/tmp. I will use @moishe flag to move it somewhere else next time I launch my development server. Thanks! – Damien Nov 04 '11 at 08:17
-1

I had the same problem, and installing the latest gae SDK solved it.

As in the case here: app engine datastore auto-clears every time project runs

Community
  • 1
  • 1
radztech
  • 439
  • 1
  • 6
  • 14