Add persistent field to an App Engine Datastore class? - google-app-engine

So if I have a class of which I have a number saved in a datastore, and then seek to add a field later, how can I prevent all my previous objects breaking? Is there a way to retroactively set those fields so they're not null?
I'm using JDO.

It depends on how you are accessing the datastore. Which runtime (python/java) and which API are you using to access the datastore? The datastore itself is schemaless, so it dosen't care what is or isn't in a certain entity. On the Java side, if you use the low level datastore API, you wouldn't have any problems accessing the "old" entities and adding in the data you want to. However, if you are using JDO or JPA to access the datastore, you might get errors accessing the entities with missing data.

Related

Deleted google app engine entities, realized it was a mistake in some cases

I accidentally deleted a bunch of entities earlier today in Google App Engine and found out later that some of them should not have been deleted. I have the keys for the entities I deleted as well as a lot of information about the entities stored in a secondary database. I was wondering if there was any way to create entities with specific keys in app engine or if there was alternative method of recovering these entities? I am very worried
I was wondering if there was any way to create entities with specific keys in app engine
You can create new entities with those same keys, just set the key property on the instance of the model before you put and it will use that key instead of generating a random one for you.
Also, check if your team has used datastore admin to take snapshots, if so, you may be able to recover them from there:
https://console.cloud.google.com/datastore/settings

In Python and GAE: How to permanently cache data from a Datastore across HTTP GET requests

I am developing an online product using GAE and Python. Certain data in my Model (i.e. Datastore) are constant across Contexts: which means for all incoming HTTP GET requests, those data don't change.
For the sake of argument, assume that said data must live in the Datastore as opposed to static pages (e.g html).
How would I set the Google App Engine Caching policies so that the Datastore is only queried once in the life of the application -- even if the product is experiencing millions of hits per day?
DISCLAIMER: I am a complete newbie to both Python and GAE.
I am presently looking into global variables, which I would use to store said query results. Not only do I not yet know how that would work, there is another problem: Different HTTP GET requests (i.e. urls) are for different portions and views of said constant data.
Thanks for any insight.
You may want to take a look at the Memcache API. It will allow you to do basically what you want - cache the results of a query (or even the resulting page as HTML) and serve it while it is available (you can set an expiry, but you will also occasionally experience cache misses where the datastore is queried anyway). Also, as #voscausa mentions, switching your datastore API from db to ndb will provide automatic caching with additional options to further modify caching behavior (docs here).

Blocking concurrent access to App Engine datastore

I'm building an application on Google App Engine that uses the datastore to store information about the current state of the server. When an Android device queries the server, a servlet gets an Entity from the datastore, modifies it, and puts it back into the datastore to update the datastore entry.
However, sometimes while one instance of the servlet has gotten the data from the datastore, another instance of the servlet does the same before the first instance puts updated data back in. This is causing synchronization issues in my application.
Is there any way to "lock" the datastore so that nothing can operate on it until the lock is released?
Thanks.
Transactions are what you're after.
Read the docs carefully though: there are strict limitations on what you can do within a transaction. Specifically, you can only query within a single entity group - that is, the set of entities with the same ancestor.

how to get the data in the datastore of App Engine by url

in Google App Engine,after using the makePersistent() to store the data in the datastore,i know how to get the data content by the key using getObjectById().
but now i wanna to get the data in the datastore by url. i think the url is created .
so the question is how the url can be created to get the data in the datastore
There is no built-in means to access the datastore through URLs. If you choose to, your application can implement URLs that return data from the datastore.
I invite you to take a look at titan-files. It's a powerful file-system abstraction on top of the DataStore and/or blob store. I'm using it for a commercial application and so far I've been very happy with it.

app engine big table

what is bigtable. Is any authentication require to create table in bigtable.where the data will be store. it is possible to view the table. we can view all the tables in bigtable, which was created by others.
I'll take your several questions one at a time:
Bigtable is the system on which AppEngine's datastore is built. It is effectively a distributed hashtable.
Authentication is required in that you must have a Google Account; you must have signed up for AppEngine; you must have created an application within AppEngine. You application will be able to access the datastore, and if you are logged in to your application's Admin Console, you can use the Datastore Viewer to inspect the contents of your application's datastore.
The data will be stored on Google Servers.
There are no tables, per se, but you can use the Datastore Viewer to view entities that reside in your application's Datastore.
No, you can not ever view the Datastore's contents that were created by other applications. Each application's view of the Datastore is completely siloed and has no connection to that of other AppEngine applications.

Resources