Datastore entity access from ODK

2019-09-08 02:12发布

I'm trying to access data that ODK has pushed into the datastore. The below code words fine when I query an entity that I created via Python, which was called "ProductSalesData". The entity name ODK has given it's data is "opendatakit.test1". When I update the data model to class opendatakit.test1(db.Model) it obviously bombs due to a sytax error. How do I call that data?

#!/usr/bin/env python

import webapp2

from google.appengine.ext import db


class ProductSalesData(db.Model):
  product_id = db.IntegerProperty()
  date = db.DateTimeProperty()
  store = db.StringProperty()

q = ProductSalesData.all()  


class simplequery(webapp2.RequestHandler):
  def get(self):
    for ProductSalesData in q:
      self.response.out.write('Result:%s<br />' % ProductSalesData.store)   


app = webapp2.WSGIApplication(
                                     [('/', simplequery)],
                                     debug=True)

1条回答
beautiful°
2楼-- · 2019-09-08 02:34

I know you tagged GAE, but do you have to access it straight through the datastore?

If not, I've had better success using the API that has already been built into aggregate: https://code.google.com/p/opendatakit/wiki/BriefcaseAggregateAPI

If you need GAE access I'd suggest the ODK developers group over on google groups - they're pretty active.

查看更多
登录 后发表回答