google-cloud-datastore

Best way to link datastore entity to its blobstore image?

Deadly 提交于 2019-12-07 08:23:28
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.LinkProperty for the base URL, post-fixing the size needed: alice.image+'=sx' I don't foresee needing anything

Google Cloud Datastore runQuery returning 412 “no matching index found”

这一生的挚爱 提交于 2019-12-07 06:36:48
问题 ** UPDATE ** Thanks to Alfred Fuller for pointing out that I need to create a manual index for this query. Unfortunately, using the JSON API, from a .NET application, there does not appear to be an officially supported way of doing so. In fact, there does not officially appear to be a way to do this at all from an app outside of App Engine, which is strange since the Cloud Datastore API was designed to allow access to the Datastore outside of App Engine. The closest hack I could find was to

Does the NDB membership query (“IN” operation) performance degrade with lots of possible values?

邮差的信 提交于 2019-12-07 06:12:06
问题 The documentation for the IN query operation states that those queries are implemented as a big OR'ed equality query: qry = Article.query(Article.tags.IN(['python', 'ruby', 'php'])) is equivalent to: qry = Article.query(ndb.OR(Article.tags == 'python', Article.tags == 'ruby', Article.tags == 'php')) I am currently modelling some entities for a GAE project and plan on using these membership queries with a lot of possible values: qry = Player.query(Player.facebook_id.IN(list_of_facebook_ids))

Why do I get Only ancestor queries are allowed inside transactions error

穿精又带淫゛_ 提交于 2019-12-07 06:10:41
问题 boolean r = ofy().transact(new Work<Boolean>() { @Override public Boolean run() { Visit visit = ofy().load().type(Visit.class) .filter(Visit.USER_ID, userID) .filter(Visit.VENUE_ID, venueID).first().get(); if (visit == null) return false; visit.setLastRequestDate(new Date(timestamp)); ofy().save().entity(visit).now(); return true; } }); and I get java.lang.IllegalArgumentException: Only ancestor queries are allowed inside transactions. for the line with the get() call. why? I'm only querying

GAE, delete NDB namespace

青春壹個敷衍的年華 提交于 2019-12-07 06:07:15
问题 In Google App Engine, using NDB, how can an entire namespace be entirely removed? The following code removes all entities: def delete(namespace): namespace_manager.set_namespace(namespace) for kind in ndb.metadata.get_kinds(): keys = [ k for k in ndb.Query(kind=kind).iter(keys_only=True) ] ndb.delete_multi( keys ) However, on the dev server, the namespace is still there when calling: ndb.metadata.get_namespaces() and, in production, exceptions are raised when trying to delete system kind, for

Difference between com.google.datastore.v1 and com.google.cloud.datastore / Missing option to disable index

你离开我真会死。 提交于 2019-12-07 05:30:11
问题 I'm currently building a Google Cloud Dataflow job which parses XML files and saves the entries using Google Datastore, bu the different Java libraries seem to be very confusing. First I found com.google.datastore.v1, which works great with Dataflow, but later on I realized that the option to excludes fields from being indexed is missing. (Most of my fields do not need an index and will never be used in a query.) Then I found com.google.cloud.datastore, which has a method named

Google App Engine Datastore / NoSQL example with ancestor queries

大兔子大兔子 提交于 2019-12-07 05:02:27
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. #!/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(db.Model): name = db.StringProperty() class Root_model(db.Model): pass # MAIN class MainHandler(webapp2

a way to convert appengine datastore Entity to my object?

自闭症网瘾萝莉.ら 提交于 2019-12-07 04:11:12
问题 Using google appengine 1.3.0 w/ java and jdo... While trying to write JDO querys for 1-to-many owned relationships, I came across a non-JDO concept that I thought was really smart. Ancestor Querys. The appengine.api.datastore.Query interface allows for scoping of a query using the parent Key. Unfortunately the results from the query are 'Entity' objects with property lists. Is there a util in the apis that will convert one of these Entity objects into my JDO object or even a simple DTO bean

gcloud.exceptions.Forbidden: 403 Missing or insufficient permissions

旧街凉风 提交于 2019-12-07 02:56:32
问题 I am a new to Google Cloud Platform. I have setup a Google VM Instance. I am facing an authentication issue on Local Machine while running the command: python manage.py makemigrations Can you please suggest some tips/steps to resolve the same ? Error Trace File "/constants.py", line 18, in <module> table_data = datastore_fetch(project_id, entity_kind) File "/datastore_helper.py", line 23, in datastore_fetch results = list(query.fetch()) File "/venv/local/lib/python2.7/site-packages/gcloud

Google App Engine and SQL LIKE

僤鯓⒐⒋嵵緔 提交于 2019-12-07 00:18:25
Is there any way to query GAE datastore with filter similar to SQL LIKE statement? For example, if a class has a string field, and I want to find all classes that have some specific keyword in that string, how can I do that? It looks like JDOQL's matches() don't work... Am I missing something? Any comments, links or code fragments are welcome As the GAE/J docs say, BigTable doesn't have such native support. You can use JDOQL String.matches for "something%" (i.e startsWith). That's all there is. Evaluate it in-memory otherwise. If you have a lot of items to examine you want to avoid loading