GoogleAppEngineLauncher: database disk image is malformed
Question: I've written a small application for Google App Engine and each time I want to
run my app I have the following error:

    
    
    *** Running dev_appserver with the following flags:
        --skip_sdk_update_check=yes --port=13080 --admin_port=8005 --clear_datastore=yes
    Python command: /usr/bin/python2.7
    INFO     2014-11-22 07:47:57,008 devappserver2.py:745] Skipping SDK update check.
    Traceback (most recent call last):
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 83, in <module>
        _run_file(__file__, globals())
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 79, in _run_file
        execfile(_PATHS.script_file(script_name), globals_)
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 997, in <module>
        main()
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 990, in main
        dev_server.start(options)
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 789, in start
        request_data, storage_path, options, configuration)
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 888, in _create_api_server
        default_gcs_bucket_name=options.default_gcs_bucket_name)
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 403, in setup_stubs
        logservice_stub.LogServiceStub(logs_path=logs_path))
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/logservice/logservice_stub.py", line 107, in __init__
        self._conn.execute(_REQUEST_LOG_CREATE)
    sqlite3.DatabaseError: database disk image is malformed
    

When I run an other application I've created, I don't have any error. I tried
some basic ideas:

  * delete/re-add the app 

  * remove the app launcher and reinstall it 

  * reboot the mac

  * locate where the database could be with some grep

Nothing worked. Any idea?


Answer: The default log database filename is `log.db`. It is stored in your app
storage directory, which by default is located in your `tempfile.gettempdir()`
directory, named `appengine.[appname].[userid]`.

The `appname` portion takes the value from your `app.yaml` (look for the
`application` entry), replaces `:` colons with underscores, and removes
everything before the last `~` tilde (if there is any).

So if your app is called `foobar` and your username is `jbj`, the corrupted
SQLite database is located in:

    
    
    `python -c 'import tempfile;print tempfile.gettempdir()'`/appengine.foobar.jbj/log.db
    

On Mac OS X, `tempfile.gettempdir()` returns a hashed path under
`/var/folders` somewhere; it is simply taken from the `TMPDIR` environment
variable, so you _should_ just be able to use:

    
    
    rm $TMPDIR/appengine.foobar.jbj/log.db
    

You can safely delete this file, it'll be re-created the next time you start
the app.

