app-engine-ndb

how to cleanly remove ndb properties

こ雲淡風輕ζ 提交于 2019-11-28 17:59:50
in my app i need to remove a few of my models properties. i checked out this link but the first issue is that the properties are on a polymodel and there is no way im going to switch to an expando for the time to remove the properties, im not even shure what could happen if i change a polymodel to an expando . so how do i remove properties from existing entities? i was thinking to set all StringProperty to None and then remove these from the model schema and redeploy. one of those properties is a BooleanProperty , i can't set this one to None right?! or an ndb.PickleProperty ... how should i

E-commerce Product Categories in Google App Engine (Python)

南笙酒味 提交于 2019-11-28 13:58:24
My goal is to create an e-commerce website where customers can see related products on any product page (similar to amazon.com). I have no idea how to get started with such a daunting task. From my research, my guess is to do the following: Create a Category kind: class Category(ndb.Model): name = ndb.StringProperty() Whenever a product is created, associate it with a Category via an ancestral relationship: parent_category = ndb.Key("Category", "Books") new_product = Product( title="Coding Horrors Book", parent=parent_category).put() Now, on each product page, I can create a query to return a

Google appengine: Task queue performance

感情迁移 提交于 2019-11-28 12:51:29
I currently have an application running on appengine and I am executing a few jobs using the deferred library, some of these tasks run daily, while some of them are executed once a month. Most of these tasks query Datastore to retrieve documents and then store the entities in an index (Search API). Some of these tables are replaced monthly and I have to run these tasks on all entities (4~5M). One exemple of such a task is: def addCompaniesToIndex(cursor=None, n_entities=0, mindate=None): #get index BATCH_SIZE = 200 cps, next_cursor, more = Company.query().\ fetch_page(BATCH_SIZE, start_cursor

How can a multi-property ndb query be successful without a composite index?

瘦欲@ 提交于 2019-11-28 05:32:37
问题 I have this entity model: class ApartCILabel(ndb.Model): project_id = ndb.IntegerProperty(indexed=True) changeset_ids = ndb.IntegerProperty(repeated=True, indexed=True) # ApartCIChangeset IDs # other properties I recently added a new type of query for these entities: keys = ApartCILabel.query(ApartCILabel.project_id == self.db_data.project_id, ApartCILabel.changeset_ids == self.key_id).fetch(keys_only=True) if keys: label = Label(db_key=keys[0], handler=self.handler) logging.debug('label

Best practice to query large number of ndb entities from datastore

删除回忆录丶 提交于 2019-11-28 02:38:35
I have run into an interesting limit with the App Engine datastore. I am creating a handler to help us analyze some usage data on one of our production servers. To perform the analysis I need to query and summarize 10,000+ entities pulled from the datastore. The calculation isn't hard, it is just a histogram of items that pass a specific filter of the usage samples. The problem I hit is that I can't get the data back from the datastore fast enough to do any processing before hitting the query deadline. I have tried everything I can think of to chunk the query into parallel RPC calls to improve

BadRequestError: app s~myapphr cannot access app dev~myapphr's data. Why?

非 Y 不嫁゛ 提交于 2019-11-28 01:34:58
I am using the Python 2.7 runtime with NDB from the 1.6.2 SDK on Google App Engine. I get the following error: BadRequestError: app s~myapphr cannot access app dev~myapphr's data Originating from this code: device = model.Key(urlsafe=device_id).get() I am accessing my app from dev.myapp.appspot.com that is aliased to myapphr. device_id was created on the same dev.myapphr version. What is going on? the dev server has a default default_partition of 'dev' and on production, HRD apps get a partition of 's'. If you create a urlsafe key on the dev server and store it as a string it will not work on

Google App Engine: ImportError: No module named appengine.ext

被刻印的时光 ゝ 提交于 2019-11-27 18:49:23
问题 I am trying to write a test for my GAE programme which uses the datastore. Following Google's Documentation, I see that I should be adding the path to my SDK into my PYTHONPATH. I did this using: import sys sys.path.remove('/usr/local/lib/python2.7/dist-packages') # Has a 'google' module, which I want to be sure isn't interfering. sys.path.insert(1,'/home/olly/google-cloud-sdk/platform/google_appengine') sys.path.insert(1, '/home/olly/google-cloud-sdk/platform/google_appengine/lib/yaml/lib')

ndb query error with datetime field - Google App Engine

给你一囗甜甜゛ 提交于 2019-11-27 17:56:27
问题 I'm having a problem and I don't find any information about. I define a field in my model like this. class Dates(ndb.model): ... date = ndb.DateTimeProperty(required = True) # I want to store date and time ... Later I try a query (now I want all the dates for a day, I don'tn mind the time): kl = Dates.query(ndb.AND(Dates.date.year == year, Dates.date.month == month, Dates.date.day == day), ancestor = customer.key).fetch(keys_only = True) dates = ndb.get_multi(kl) But I get this error log:

Google App Engine ndb equivalent for modelname_set (backreference property)

China☆狼群 提交于 2019-11-27 16:21:12
问题 Is there an equivalent for modelname_set (a back-referenced property) in Google App Engine's NDB? In the old DB a Model entity had described the back-reference property as: The name of the back-reference property defaults to modelname_set (with the name of the model class in lowercase letters, and "_set" added to the end), and can be adjusted using the collection_name argument to the ReferenceProperty constructor. I noticed this property does not seem to exist with NDB db.Model instances.

Maintain uniqueness of a property in the NDB database

扶醉桌前 提交于 2019-11-27 16:12:15
问题 An NDB model contains two properties: email and password . How to avoid adding to the database two records with the same email ? NDB doesn't have UNIQUE option for a property, like relational databases do. Checking that new email is not in the database before adding—won't satisfy me, because two parallel processes can both simultaneously do the checking and each add the same email . I'm not sure that transactions can help here, I am under this impression after reading some of the manuals.