app-engine-ndb

App engine datastore denormalization: index properties in the main entity or the denormalized entity?

北城以北 提交于 2020-01-16 02:55:13
问题 Consider the classic example of blog data modelling, where we have a Blog entity with many properties, and we want to list the latest blogs in a page. It makes sense to denormalize the BlogPost entity into a BlogPostSummary entity which will be shown in the list view, avoiding fetching and deserializing many unwanted properties. class BlogPost(db.Model): title = db.StringProperty() content = db.TextProperty() created = db.DateProperty() ... class BlogPostSummary(db.Model): title = db

updating an entity's property without retrieving the entity from the NDB

我只是一个虾纸丫 提交于 2020-01-15 04:45:07
问题 I would like to update a property of an entity that has a lot of properties. If I understand it correctly, whenever I retrieve the entity from the datastore by entity = key_of_entity.get() to later update it's property entity.some_property += 1 entity.put() I am charged for read of every property of that entity? Since this entity has quite a few properties, such reading over and over again can be quite expensive. Is there any way to update an entity's property without having to do a read on

Google App Engine - Can't Update Budget

本秂侑毒 提交于 2020-01-06 04:25:06
问题 I have billing enabled on my project, and have even issued a $10 payment just to test out the process (it works). But I am unable to change my daily budget on the google app engine dashboard. I go to "Billing Status" section. I am entering the new daily budget and I hit the "submit" button. I am getting the not very informative error: "There was an error processing the request". So I'm stuck without being able to update my budget, and my quota has exceeded for instance hours. My users are

ndb ComputedProperty filtering

半世苍凉 提交于 2020-01-04 17:32:21
问题 I have a User ndb.Model which has a username StringProperty that allows upper en lower case letters, at some point I wanted to fetch users by username but have the case forced to lowercase for the filtering. Therefor I added a ComputedProperty to User: username_lower which returns the lowercase version of the username as follows: @ndb.ComputedProperty def username_lower(self): return self.username.lower() then I filter the query like so: query = query.filter(User.username_lower==username

ndb ComputedProperty filtering

做~自己de王妃 提交于 2020-01-04 17:32:06
问题 I have a User ndb.Model which has a username StringProperty that allows upper en lower case letters, at some point I wanted to fetch users by username but have the case forced to lowercase for the filtering. Therefor I added a ComputedProperty to User: username_lower which returns the lowercase version of the username as follows: @ndb.ComputedProperty def username_lower(self): return self.username.lower() then I filter the query like so: query = query.filter(User.username_lower==username

Best way to get distinct values

China☆狼群 提交于 2020-01-04 05:13:04
问题 I'm using Google-Appengine-NDB. And I'm tried to get distinct values from database but it's not working. Now my code is: query_set = cls.query().order(cls.ls) # Getting ordered queries. set_of_field = set([data.field for data in query_set]) # And using this loop for differ.` But the loop is taking too long time (over 12 sec). Please help me, how can I speed up, or how to get distinct values from ndb? 回答1: Try the distinct query, if your field is indexed you can use this: https://developers

How is ndb.StringProperty equals a python string?

喜夏-厌秋 提交于 2020-01-04 05:06:23
问题 I have this ndb Model class class foo(ndb.Model): abc = ndb.StringProperty() Now when I used abc like this: if foo.abc == "a": print "I'm in!" It gets into the if block and prints I'm in! How's this possible? I also tried printing foo.abc , it returned StringProperty('abc') 回答1: You have to instantiate an instance of class to use properties properly. class Foo(ndb.Model): abc = ndb.StringProperty() foo = Foo() foo.abc = 'some val' print foo.abc # prints 'some val' print foo.abc == 'a' #

Ever see duplicate IDs when using Google App Engine and ndb?

爷,独闯天下 提交于 2020-01-04 04:25:06
问题 class Entries(ndb.Model): description = ndb.StringProperty() seqid = ndb.IntegerProperty() link = ndb.StringProperty() group = ndb.StringProperty() timestamp = ndb.StringProperty() referrals = ndb.StringProperty(repeated=True) The two entries in the picture are created by two different users. The user is the parent of the Entry. I get a duplicate ID on production but not on local. Also, it's always this same id number (but it is certainly not hard coded anywhere) As the parent is the user, i

Partly update App Engine entity

懵懂的女人 提交于 2020-01-03 05:55:14
问题 I'm building a sync engine with App Engine and when I receive data from the client I want to store an object but I don't care if it already exists or not. It works nice today if I always send all properties from the client when updating. But I want... some internal properties not to be known by the client and still survive the update the client to be able to only send the changed values avoid fetching all objects before updating them as there can be quite few objects that need updates Do I

Storing song, artist and album data on App Engine

做~自己de王妃 提交于 2020-01-03 05:04:19
问题 I need to store information on artists, albums and songs in Google App Engine for a project I'm working on. The information is meta data taken from a directory of MP3s (using Python) that needs to be sent to App Engine for display to users. Along with the meta data, the song's path will need to be stored. Currently while scanning I'm storing the data in an list of dictionaries named Artists, each artist dictionary has a name and a list of Album dictionaries and each Album dictionary has a