Google App Engine Launcher delete datastore - google-app-engine

I am developing a web application using Google AppEngine (GAE).
I have make some examples using dataStore (free, non-relational) using Google AppEngine Launcher (GAEL). All is correct. However I'd like delete the datastore before to deploy an application.
I have read that I have to use the command
--clear_datastore
I don't know like running the server to delete the data store when I deploy or re-deploy the application.
I have chech some ways, for example I have write in the Application Settings(Edit==>Application Settings) in the GAEL some commands:
--clear_datastore
--clear_datastore /<ApplicationName>
--clear_datastore <ApplicationName>/
--clear_datastore <ApplicationName>
any idea?
Thank you.
Jose

The clear_datastore flag is only used to clear the development datastore which is running on your local machine with the dev_appserver. If you want to clear this development datastore, then when you run the dev appserver you can use the flags:
dev_appserver.sh --clear_datastore=yes <ApplicationName>
An important thing to note is that this only clears the development datastore. The development datastore does not get uploaded when you deploy the application. So you shouldn't be worried about clearing the local datastore before deploying the application.
If you want to delete entities that are already in your production server (running on App Engine), then you cannot do this from the command line using dev_appserver.sh. You can do this using the Datastore Admin tool in the AppEngine console. You can follow the instructions here to bulk delete data. An important note is that you have to enable the Datastore Admin tool first by following these instructions.

Related

How to use Google Cloud SDK in local environment

I am currently using Google's 'legacy standalone SDK' for management of my google app engine python projects. This provides a nice GUI where I can select and run a project locally and then deploy it when I'm happy with testing.
I recently received the following message from Google '... App Engine app that has used the legacy standalone SDK in the past 30 days, and need to be migrated to Cloud SDK' so I installed the Cloud SDK.
The provided Google Cloud SDK Shell a) runs as a dos window, and b) appears to duplicate the on-line (live) Dashboard. Given that I can't change (local) code and deploy without testing, my questions are:-
1) how do I run a project locally?
2) how do I view local logs?
3) when happy, how do I deploy?
or... is there GUI for the Local Environment?
or... is the above documented somewhere that I have not found?
Many thanks and apologies if this is a dumb question.
David
On July 30, 2019, the standalone App Engine SDK is deprecated. Here you can check documentation how to migrate from AppCft to gcloud command line
How to test your application locally?
For Python you can use Local Development Server that includes Cloud Datastore Emulator. (There is also solution for Java Java 8 Local Development Server).
How to view logs locally?
In python to debug your code from the command line use interactive console. You have to import to your code PDB debbuger
How to deploy application?
You deploy your app with gcloud command gcloud app deploy. Cloud SDK does not include GUI for deployment.

Local or development Google Cloud Firestore database with App Engine

In my previous App Engine projects I used the Cloud Datastore, and during development I could debug my app on the local server and it would use a local database, stored in a file I could wipe out if I wanted to start from scratch.
With Cloud Firestore, even when I'm running locally it's talking to my real cloud database. Is there still a local option? Note that I'm not talking about client-side persistence, I'm talking about a mock development DB.
Google recommends setting up multiple projects if you want dev/staging/production, and I'm guessing that's the answer, but I'd like to know before adjusting my workflow.
I think (now only a few months later) that this is supported. When I run my app, using dev_appserver.py, I see a message
INFO 2019-02-14 00:08:56,030 admin_server.py:150] Starting admin server at: http://localhost:8000
Going to that URL shows me all the instances I have been seeing. These seem to persist even when the dev_appserver is restarted. Reading this and other posts I was convinced that my development was using my actual cloud database, but going to https://console.firebase.google.com/project/myproject was showing completely different content.
Just to be sure (because google is google and everything is named the same) I'm using an appengine app and a gcloud project, storing things to Firestore using ndb.Models...
Oh, but careful. My app I was also using the cloudstorage (blobstore?) and even though the localhost:8000 showed these, THESE WERE THE REMOTE INSTANCES.
There is a local emulator for Firestore when using the Firebase CLI:
https://firebase.google.com/docs/rules/emulator-setup

Can I build a golang command-line tool that talks to a localhost appengine datastore?

I have a standard appengine + datastore app (not flex) built in golang using these APIs:
google.golang.org/appengine
google.golang.org/appengine/datastore
I'm trying to write a command-line tool in golang to do various batch things with the datastore, such as migrating data, running consistency checks and so forth. The cli tool uses this API:
cloud.google.com/go/datastore
I can get the cli tool to talk to my hosted appengine datastore, but I can't figure out how to get it to talk to the localhost dev_appserver.py datastore. The 1st call to datastore datastoreClient.GetAll(ctx, q, nil) always hangs.
I read some of the API code, and it looks like I need to set DATASTORE_EMULATOR_HOST to point to http://localhost:some_port, but I can't get this to work w/ any of the 3 servers that are started up by dev_appserver.py (ports 8000, 8080, 53536).
Am I on the right track? I've read a lot of posts & help, but they're either too old, or talk about appengine flex and so forth.
Thanks.
You could always use the standalone Datastore emulator.
Install it:
gcloud components install cloud-datastore-emulator
Start the emulator (do this in a background shell, the command runs in the foreground):
gcloud beta emulators datastore start
And then setup the environment for your application by running:
$(gcloud beta emulators datastore env-init)
Then run your app, and it should pick up and connect to the Datastore emulator automatically.

Application Default Credentials not working locally with App Engine

Having a tough time getting the Default Application Credentials to load in the dataflow SDK when running locally in a java app engine project developing on OS X. Runs fine when deployed.
According to this the dev app server doesn't support them, and you're meant to use the gcloud command line tool's command: gcloud preview app run - but according to the official Google Group for the SDK here that command was deprecated in Jan 2016.
So I seem to be stuck between a rock and a hard place... Does anyone know how to get the Application Default Credentials to work locally with an App Engine app?
I'm trying to use the Dataflow API and it just throws up when it starts making use of the cloud storage api which is the first thing the Pipeline does because it can't seem to load the correct credentials from the environment variables ( that are definitely set on the ENV and in the appengine-web.xml <env-variables> element ) or from the ~/.config/cloud/default_application_credentials.json file.
Cheers!
Can you try running the following command and see if it solves it?
gcloud auth application-default login
This is fully supported (but poorly documented) within the dev appserver. There is a very well answered question that gives you step by step instructions here: Unable to access BigQuery from local App Engine development server

How to preserve development datastore from clearing itself on reboot

I need to change my local datastore path of APP Engine. I have followed methods specified here How can I persist the local datastore for GoogleAppEngineLauncher between reboots? . I tried changing datastore path but it didn't work. I am using App Engine SDK 1.6.4, Python 2.7 and NDB as datastore on Windows 7. Also I could not find default datastore location on my computer as stated in dev_appserver.py -help output (which is a temp location but I searched while application was running and datastore was serving).
My objective is to stop local datastore cleaning itself on each launch (I am using launcher).
The datastore SHOULD persist between reboots.
When you shut down, the server you should see a message "Applying all pending transactions and saving the datastore" in the console. If not, you maybe seeing the following issue (two questions, same issue, first one has a workaround)
GAE SDK 1.6.4 dev_appserver datastore flush
App Engine local datastore content does not persist

Resources