GAE datastore - count records between one minute ago and two minutes ago?
- by Arthur Wulf White
I am using GAE datastore with python and I want to count and display the number of records between two recent dates. for examples, how many records exist with a time signature between two minutes ago and three minutes ago in the datastore.
Thank you.
#!/usr/bin/env python
import wsgiref.handlers
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from datetime import datetime
class Voice(db.Model):
when = db.DateTimeProperty(auto_now_add=True)
class MyHandler(webapp.RequestHandler):
def get(self):
voices = db.GqlQuery(
'SELECT * FROM Voice '
'ORDER BY when DESC')
values = {
'voices': voices
}
self.response.out.write(template.render('main.html', values))
def post(self):
voice = Voice()
voice.put()
self.redirect('/')
self.response.out.write('posted!')
def main():
app = webapp.WSGIApplication([
(r'.*', MyHandler)], debug=True)
wsgiref.handlers.CGIHandler().run(app)
if __name__ == "__main__":
main()