google-cloud-datastore

Unable to get ID of newly-created JDO persistent entity using GAE/J DataNucleus plug-in version 2.1.2

谁都会走 提交于 2019-12-04 10:30:01
My problem I am porting my application from version 1.x to 2.0 of the DataNucleus plug-in for GAE/J using the new 1.7.5 GAE/J SDK. This changes my JDO version from 2.3 to 3.0.1. My persistent entity class has a primary key of type encoded string, along with read-only access to the object’s numeric ID. Each instance is the sole member of its entity group (children and parent are linked by numeric ID only). Previously, I have been able to create and persist a new MyEntity instance and then immediately access its numeric ID to store in the parent MyEntity instance’s list of child IDs. Now I find

How to dynamically build JDO Queries on multiple parameters

北慕城南 提交于 2019-12-04 10:16:49
One can easily use JDO syntax to query on multiple parameters as follows: //specify the persistent entity you're querying and you filter usign params query = pm.newQuery(MyClass.class, " customer == paramCustomer && date >= paramStartDate && date <=paramEndDate "); // declare params used above query.declareParameters("com.google.appengine.api.users.User paramCustomer, java.util.Date paramStartDate, java.util.Date paramEndDate"); //pass the object declared as params MyClassList = (List<MyClass>) query.execute(user, startDate, endDate); It's straightforward to programmatically build a string

what's the practical difference between google datastore nosql and google bigquery sql?

孤街浪徒 提交于 2019-12-04 09:56:41
I want to know how to evaluate one tool over another. My major concern is as following: In google datastore, we define 'kind'. Each 'entities' has 'properties'. Then the datastore backends use those properties to index data for future query. The query itself use almost the same idea in SQL, though different syntax, to filter data and find what we want. If you index every property, the index metadata would be even bigger than real data. Google bigquery uses it's dialect of SQL. And it's fully managed so users don't have to worry about the scaling problem. So my question is, what's the purpose

Query response size limit on appengine?

懵懂的女人 提交于 2019-12-04 09:11:35
Appengine docs mention a 1Mb limit on both entity size and batch get requests (db.get()): http://code.google.com/appengine/docs/python/datastore/overview.html Is there also a limit on the total size of all entities returned by a query for a single fetch() call? Example query: db.Model.all().fetch(1000) Update: As of 1.4.0 batch get limits have been removed! Size and quantity limits on datastore batch get/put/delete operations have been removed. Individual entities are still limited to 1 MB, but your app may batch as many entities together for get/put/delete calls as the overall datastore

App engine NDB: how to access verbose_name of a property

纵然是瞬间 提交于 2019-12-04 08:34:15
suppose I have this code: class A(ndb.Model): prop = ndb.StringProperty(verbose_name="Something") m = A() m.prop = "a string value" Now of course if I print m.prop, it will output "a string value" while in fact it's a StringProperty instance. So verbose_name can't be accessed the "normal" way, i.e m.prop._verbose_name . I read the code and found a way to access it: m._properties["prop"]._verbose_name , it works, but it looks hacky o_o. So tell me, is there another way to do it? Note: I'm talking about the NDB API, not the old one Use a class attribute: A.prop._verbose_name . Or m.__class__

App Engine (Python) Datastore Precall API Hooks

喜夏-厌秋 提交于 2019-12-04 07:43:01
Background So let's say I'm making app for GAE, and I want to use API Hooks . BIG EDIT : In the original version of this question, I described my use case, but some folks correctly pointed out that it was not really suited for API Hooks. Granted! Consider me helped. But now my issue is academic: I still don't know how to use hooks in practice, and I'd like to. I've rewritten my question to make it much more generic. Code So I make a model like this: class Model(db.Model): user = db.UserProperty(required=True) def pre_put(self): # Sets a value, raises an exception, whatever. Use your

Google App Engine - getting count of records that match criteria over 1000

半腔热情 提交于 2019-12-04 06:59:40
I've read in multiple locations that GAE lifted the 1000 record limit on queries and counts, however, I can only seem to get a count of the records up to 1000. I won't be pulling more than 1000 queries at a time, but the requirements are such that I need a count of the matching records. I understand you can use cursors to "paginate" through the dataset, but to cycle through just to get a count seems a bit much. Presumably when they said they "lifted" the limit, it was the hard limit - you still need to cycle through the results 1000 at a time, am I correct? Should I be using a method other

“BadValueError: Property category is required” on GAE

这一生的挚爱 提交于 2019-12-04 06:34:27
问题 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)

How to check duplicate data in my datastore and display the error?

落爺英雄遲暮 提交于 2019-12-04 06:28:50
问题 Am working on GAE,GAE datastore and python. This is my dbmodel.py, class Customer(db.Model): name = db.StringProperty(required=True) phone = db.PhoneNumberProperty(required=True) email = db.EmailProperty(required=True) this is my main.py, class AddCustomerHandler(BaseHandler): def get(self): template = jinja_environment.get_template('template/addcustomer.html') self.response.out.write(template.render(template_values)) def post(self): input_fullname=self.request.get('fullname') input_phone

Unable to access ID property from a datastore entity

假装没事ソ 提交于 2019-12-04 06:19:14
Using Google App Engine SDK and Python, I'm facing an issue : I'm unable to access the ID property of a given entity properties. The only properties I can access are those defined in my class Model, plus the key property (see answer below) : class Question(db.Model): text = db.StringProperty() answers = db.StringListProperty() user = db.UserProperty() datetime = db.DateTimeProperty() I can access text, answers, user, datetime and key properties just fine. However, I can't access the ID property. For example, after fetching all entities (using Question.all()) : # OK Within a template, this will