Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Engine: Development datastore cleared each time I turn off my computer. How to avoid this?

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...

like image 860
Damien Avatar asked Nov 03 '11 07:11

Damien


3 Answers

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.

like image 164
Moishe Lettvin Avatar answered Nov 10 '22 22:11

Moishe Lettvin


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)

like image 43
TrophyGeek Avatar answered Nov 10 '22 23:11

TrophyGeek


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

like image 3
mrauto Avatar answered Nov 10 '22 22:11

mrauto