google-cloud-datastore

Best way to link datastore entity to its blobstore image?

╄→гoц情女王★ 提交于 2019-12-08 05:48:44
问题 Let's say I have a model for my email address book: class contact(db.Model): email = db.EmailProperty() image = #Hmm. My contacts' images will be stored in the Blobstore, and served at various sizes. So, should I use a db.ReferenceProperty(BlobInfo) such that I can serve it by doing: get_serving_url(alice.image.key, size=x) Or should I use a db.StringProperty so that I don't have to make the second read in order to get the key: get_serving_url(alice.image, size=x) Or should I use a db

google app engine reverse key order query

本小妞迷上赌 提交于 2019-12-08 05:39:00
问题 I'm using Google App Engine (GAE) GO version of a datastore query. I want to get the list of keys in reverse order. Forward order works, but when I add the hyphen to the order clause it fails. q = q.Order("-__key__") with the error: Error: API error 4 (datastore_v3: NEED_INDEX): no matching index found. Is this a bug? or not supported? 回答1: Not supported. q.Order("__key__") uses the EntitiesByKind index, which is ascending-only. See https://developers.google.com/appengine/articles/storage

Google App Engine - update_indexes error

做~自己de王妃 提交于 2019-12-08 05:34:42
问题 I have a Java app deployed on app engine and I use appcfg.py of the Python SDK to vacuum and update my indexes. Yesterday I first ran vacuum_indexes and that completed successfully - i.e. it en-queued tasks to delete my existing indexes. The next step was probably a mistake on my part - I then ran update_indexes even though my previous indexes weren't yet deleted. Needless to say that my update_indexes call errored out. So much so that now when I look at my app engine console, it shows the

Google App Engine Datastore: Dealing with eventual consistency

半世苍凉 提交于 2019-12-08 05:30:28
问题 I am developing a GAE web application and I need to create and remove associations among instances of two Entities which have no ancestor relationship (also consider the same instance may have multiple associations that may vary in time while the ancestor relationship, once created, can't be removed). I have experienced the 'eventual consistency' policy which means data in my web page are not refreshed coherently with the relationships I am creating/removing. However I have seen that by

How much quota does an appengine datastore Query cost?

北慕城南 提交于 2019-12-08 04:46:29
In the appengine Billing and Budgeting Resources page, it says that the cost of a "Query" maps to "1 read + 1 small per entity retrieved", whereas a "Query (keys only)" maps to "1 read + 1 small per key retrieved". This seems like a typo to me. It would seem that a Query would still need to perform a full "get" operation on each entity returned. Is this assumption incorrect? I would have expected the cost of a "Query" to be "1 read + 1 read per entity retrieved". This definitely looks like a typo. cpm_usd looks like a deprecated way to measure costs, linked to the previous pricing model. With

Why does Dataflow erratically fail in Datastore access?

孤者浪人 提交于 2019-12-08 04:13:42
问题 My simple Dataflow pipeline successfully copies multiple Kinds from one project's Datastore to another in most cases. But in certain Kinds (about 5% of them), we always get these errors. Dataflow retries 4-8 times with a delay of about 75 seconds, and then the pipeline fails. How can I diagnose and resolve this? EDIT: The answer includes: (1) there was a bug in the Datastore library used by Dataflow; after they fixed this bug, you can see the underlying cause and (2) the default batch size

Google App Engine Datastore / NoSQL example with ancestor queries

谁说我不能喝 提交于 2019-12-08 03:54:46
问题 I'm very used to SQL, and not the NoSQL paradigm of App Engine Datastore, so I had to write a piece of example code to understand how to do ancestor queries correctly. Thought I'd share it with you here; maybe it's interesting to someone. 回答1: #!/usr/bin/env python # -*- coding: utf-8 -*- import webapp2 from google.appengine.ext.webapp.util import run_wsgi_app import logging from google.appengine.ext import db # MODELS class Child_model(db.Model): name = db.StringProperty() class Parent_model

Objectify: Handle race condition to prevent duplicate account creation

久未见 提交于 2019-12-08 03:27:57
问题 I'm using Google App Engine and Datastore with objectify. I'm trying to create an account for a user (Google user), so I need to check if that users exist, and if not, create an account for that user, but I'm facing the fact that sometimes the account is created twice if I spam the createAccount API method @ApiMethod(name = "account.google.create") public Account createGoogleAccount(final User user) throws OAuthRequestException { if (user == null) { throw new OAuthRequestException(

Migration from Google cloud sql to datastore

核能气质少年 提交于 2019-12-08 03:22:15
问题 Is there an easy way to migrate a large (100G) Google cloud sql database to Google datastore? The way that comes to mind is to write a python appengine script for each database and table and then put it into the datastore. That sounds tedious but maybe it has to be done? Side note, the reason I'm leaving cloud sql is because I have jsp pages with multiple queries on them and they are incredibly slow even with a d32 sql instance. I hope that putting it in the datastore will be faster? There

Does GAE Datastore support eager fetching?

三世轮回 提交于 2019-12-08 02:39:35
问题 Let's say I want to display a list of books and their authors. In traditional database design, I would issue a single query to retrieve rows from the Book table as well as the related Author table, a step known as eager fetching . This is done to avoid the dreaded N+1 select problem : If the Author records were retrieved lazily, my program would have to issue a separate query for each author, possibly as many queries as there are books in the list. Does Google App Engine Datastore provide a