Skip to content

Instantly share code, notes, and snippets.

@artschwagerb
Created November 14, 2013 18:43
Show Gist options
  • Save artschwagerb/7472133 to your computer and use it in GitHub Desktop.
Save artschwagerb/7472133 to your computer and use it in GitHub Desktop.
Database Routers (settings.py)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'anotherdatabase',
'USER': 'anotherusername',
'PASSWORD': 'anotherpassword',
'HOST': '192.168.1.1',
'PORT': '',
},
'master': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'anotherdatabase',
'USER': 'anotherusername',
'PASSWORD': 'anotherpassword',
'HOST': '192.168.1.1',
'PORT': '',
},
'slave1': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'anotherdatabase',
'USER': 'anotherusername',
'PASSWORD': 'anotherpassword',
'HOST': '192.168.1.2',
'PORT': '',
},
'slave2': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'anotherdatabase',
'USER': 'anotherusername',
'PASSWORD': 'anotherpassword',
'HOST': '192.168.1.3',
'PORT': '',
},
}
DATABASE_ROUTERS = ['my_project.routers.MasterSlaveRouter']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment