Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fun with Django and Databases

Fun with Django and Databases

A talk I gave at EuroPython 2010

Andrew Godwin

July 19, 2010

More Decks by Andrew Godwin

Other Decks in Programming


  1. Django and Databases Fun with

  2. ""Andrew speaks English like a machine gun speaks bullets."" Reinout

    van Rees
  3. Introduction

  4. from django.db import models

  5. First, an aside

  6. ""When all you have is a hammer, everything looks like

    a nail"" Abraham Manslow (paraphrased)
  7. Also, "NoSQL"? Really?

  8. queryset.raw()

  9. qs = Teacher.objects.raw(""" SELECT t.name, COUNT(s.id) FROM school_teacher AS t

    INNER JOIN school_student AS s ON t.id = s.teacher_id GROUP BY t.name HAVING COUNT(s.id) > 2 """)
  10. queryset.aggregate()

  11. qs = Teacher.objects.annotate( num_students = models.Count('student') ).filter(num_students__gt=2)

  12. Search haystack __search=

  13. Schema Changes

  14. Changing Requirements

  15. Dynamic/Unknown Data

  16. Document Databases MongoDB CouchDB

  17. Key-Value Stores Redis Cassandra

  18. Redis Sets Sorted Sets Hashes Pub/Sub Atomicity

  19. Message Queues AMQP Celery

  20. Various Others Graph databases Filesystems VCSs

  21. Conclusion

  22. Thanks. Andrew Godwin @andrewgodwin http://aeracode.org