google-cloud-datastore

How to enable Cloud Firestore Native Mode using API / command line?

£可爱£侵袭症+ 提交于 2019-12-02 07:50:46
问题 I'm writing a script for setting up a Google Cloud project and I'd like to use Firestore. A new project, however, is by default in Datastore mode. Switching to Firestore can easily be done using the web interface in the cloud console but I'd like to automate it. Is there any API or command line tool (gcloud? firebase?) for enabling it? 回答1: Unfortunately, as of today (30 Apr 2019), there is no API or command line to set the mode for Cloud Firestore. 来源: https://stackoverflow.com/questions

“BadValueError: Property category is required” on GAE

核能气质少年 提交于 2019-12-02 07:48:48
I am trying to make a simple webapp html page that prints out data given from a datastore. However, I am continually running the following error: raise BadValueError('Property %s is required' % self.name) BadValueError: Property category is required I have heard that this is because I must initialize my properties beforehand but as of yet, have not found an appropriate way to do this. The following is placed in model.py class Question(db.Model): category = db.StringProperty(required=True) question = db.StringProperty(required=True, multiline=True) creator = db.StringProperty(required=True,

How can I create two unique, queriable fields for a GAE Datastore Data Model?

佐手、 提交于 2019-12-02 07:48:00
First a little setup. Last week I was having trouble implementing a specific methodology that I had constructed which would allow me to manage two unique fields associated with one db.Model object. Since this isn't possible, I created a parent entity class and a child entity class, each having the key_name assigned one of the unique values. You can find my previous question located here , which includes my sample code and a general explaination of my insertion process. On my original question, someone commented that my solution would not solve my problem of needing two unique fields associated

How to model a unique constraint in GAE ndb

前提是你 提交于 2019-12-02 07:46:41
I want to have several "bundles" (Mjbundle), which essentially are bundles of questions (Mjquestion). The Mjquestion has an integer "index" property which needs to be unique, but it should only be unique within the bundle containing it. I'm not sure how to model something like this properly, I try to do it using a structured (repeating) property below, but there is yet nothing actually constraining the uniqueness of the Mjquestion indexes. What is a better/normal/correct way of doing this? class Mjquestion(ndb.Model): """This is a Mjquestion.""" index = ndb.IntegerProperty(indexed=True,

How to save an entity in GAE datastore only if it does not exist while preventing race conditions

馋奶兔 提交于 2019-12-02 07:45:20
I am trying to save an entity to Google App Engine Datastore only if it does not exist, if it does the thread should not continue. Main issue is: I want to prevent any race conditions, such that if 2 threads are doing this at the same time only one would succeed in saving the entity. I am not sure what is the best approach for this, would using Transactions work or one must rely on other solutions such as using Memcache Please provide answer in low level API in java Assuming that the both threads are trying to save an entity with the same key , then this code: datastore.add(entity); will do

How to connect to the local google cloud Datastore db?

纵饮孤独 提交于 2019-12-02 07:27:15
I've GAE application which creates some data in the Google Cloud Datastore and stores some binary files into the Google Cloud Storage - let's call the application WebApp . Now I have a different application running on the Google compute engine. Let's call the application ComputeApp . The ComputeApp is a backend process which is processing data created by the WebApp . I asked here in this question previously which API can I use to communicate with Datastore from the ComputeApp . As suggested by @proppy, I implemented the Datastore communication using of the Google Cloud Datastore API .

Can't execute a distinct projection query

ⅰ亾dé卋堺 提交于 2019-12-02 06:05:14
I have a simple little "Observation" class: from google.appengine.ext import ndb class Observation(ndb.Model): remote_id = ndb.StringProperty() dimension_id = ndb.IntegerProperty() metric = ndb.StringProperty() timestamp_observed = ndb.StringProperty() timestamp_received = ndb.DateTimeProperty(auto_now_add=True) @classmethod def query_book(cls): return cls.query() I can run projection queries against the Datastore to return only certain columns. E.g: observations = Observation.query().fetch(projection=[Observation.dimension_id]) This works nicely, but I only want unique results. The

Write/Read with High Replication Datastore + NDB

此生再无相见时 提交于 2019-12-02 06:02:17
问题 So I have been reading a lot of documentation on HRD and NDB lately, yet I still have some doubts regarding how NDB caches things. Example case: Imagine a case where a users writes data and the app needs to fetch it immediately after the write. E.g. A user creates a "Group" (similar to a Facebook/Linkedin group) and is redirected to the group immediately after creating it. (For now, I'm creating a group without assigning it an ancestor) Result: When testing this sort of functionality locally

Datastore fetch VS fetch(keys_only=True) then get_multi

岁酱吖の 提交于 2019-12-02 05:08:02
问题 I am fetching multiple entities 100+ from datastore using the below Query return entity .query(ancestor = ancestorKey ).filter( entity .year= myStartYear ).order( entity .num).fetch() Which was taking a long time ( order of a few seconds ) to load. Trying to find an optimum way, I created exactly 100 entities, found that it takes anywhere between 750ms ~ 1000ms to fetch the 100 entities on local server, which is a lot of course. I am not sure how to get around a single line fetch to make it

TransactionFailedError (too much contention…) when reading (cross-group) entities from datastore

此生再无相见时 提交于 2019-12-02 04:34:25
I’m investigating again the unexpected occurrence of TransactionFailedError (too much contention on these datastore entities... in cases, where the code only reads entity groups that are blamed for the contention problems. Setup GAE standard environment, Python 2.7 with NDB (SDK 1.9.51). I managed to observe the error in an isolated app (only me as user) where the same request handler is executed in a task queue and read/write access to the entity-groups mentioned below is only done by this handler. The handler is executed a few times per second and basically is a migration / copy task to move