Skip to content

Instantly share code, notes, and snippets.

@andylolz
Created October 9, 2012 22:03
Show Gist options
  • Select an option

  • Save andylolz/3861722 to your computer and use it in GitHub Desktop.

Select an option

Save andylolz/3861722 to your computer and use it in GitHub Desktop.
Hammer the datastore
def hammer_the_datastore():
demo = models.School.all().filter('url_slug', 'demonstration').fetch(1)[0]
donations = []
print("Generating donations . . .")
for x in range(0, 500):
donations.append(models.Donation(
school=demo,
num_cells=10,
preferred_cell_index=-1,
donor_first_name="Andy",
donor_last_name="Lolz",
donor_email="a.lulham@gmail.com",
status=models.Donation.Status.DELETED,
))
print("done. Putting to datastore . . .")
attempts = 0
while attempts < 5:
attempts = attempts + 1
try:
db.put(donations)
print("done.")
return
except:
print("failed at attempt %d" % attempts)
print("Giving up :(")
@andylolz
Copy link
Author

Cleaning up:

db.delete(models.Donation.all().filter('donor_last_name', 'Lolz').fetch(500))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment