import datetime from google appengine ext import ndb from models impor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import datetime
from google.appengine.ext import ndb
from models import Event
class EventBeacon(ndb.Expando):
pass
def drop_event_beacons():
query = EventBeacon.query()
total_deleted = 0
while True:
keys = query.fetch(1000, keys_only=True)
if not keys:
break
ndb.delete_multi(keys)
total_deleted += len(keys)
print "total deleted: %s" % total_deleted
def drop_events():
query = Event.query(Event.timestamp < datetime.datetime(2014, 9, 1, 0, 0, 0))
total_deleted = 0
while True:
keys = query.fetch(1000, keys_only=True)
if not keys:
break
ndb.delete_multi(keys)
total_deleted += len(keys)
print "total deleted: %s" % total_deleted