Skip to content

Instantly share code, notes, and snippets.

@theriverman
Last active June 30, 2017 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theriverman/16f06f13962aa6767b68d4f93c8f5074 to your computer and use it in GitHub Desktop.
Save theriverman/16f06f13962aa6767b68d4f93c8f5074 to your computer and use it in GitHub Desktop.
Postgresql Auto-fallback (initial)
DATABASES = {
"follower": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "follower",
"USER": "root",
"HOST": "54.34.65.24",
"PORT": "3306",
},
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "application",
"USER": "root",
"HOST": "54.34.65.23",
"PORT": "3306",
},
}
___________________________________________________________
Replace the target database in common.py (try migrating database settings to local.py)
sed -Ei 's/psql/psql-slave/g' psql_setting #Master to Slave
sed -Ei 's/psql-slave/psql/g' psql_setting #Slave to Master
# Exact match:
sed -i 's/\<$basename\>/${basename}_yesterday/g' file.txt
https://stackoverflow.com/questions/26608906/django-multiple-databases-fallback-to-master-if-slave-is-down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment