Skip to content

Instantly share code, notes, and snippets.

View artschwagerb's full-sized avatar

Brian Artschwager artschwagerb

View GitHub Profile
@artschwagerb
artschwagerb / routers.py
Created November 14, 2013 18:38
Django Database Router
import random
class MasterSlaveRouter(object):
def db_for_read(self, model, **hints):
"""
Reads go to a randomly-chosen slave.
"""
return random.choice(['master','slave1', 'slave2'])
def db_for_write(self, model, **hints):