1

What I am trying to say is, I have two database and they are replicates. Is it possible for django to have settings that if first (primary db) is down / cannot be connected then connect to the second one until the first one is back up?

I believe this can be done in server side, but I am wondering if it can be done with django easily instead of touching the db servers?

Dora
  • 6,776
  • 14
  • 51
  • 99
  • https://stackoverflow.com/questions/27401779/dynamically-set-database-based-on-request-in-django/27422908#27422908 check this – Shiva Dec 21 '17 at 07:31
  • not sure, but just a suggestion for every request check database connected or not , if timeout comes just change the connection. – Shiva Dec 21 '17 at 07:34
  • 2
    Possible duplicate of [Django Multiple Databases Fallback to Master if Slave is down](https://stackoverflow.com/questions/26608906/django-multiple-databases-fallback-to-master-if-slave-is-down) – Logovskii Dmitrii Dec 21 '17 at 08:07
  • @Shiva to my understanding with the other forums, I have to make a middleware then add it into my middleware section? – Tsuna Jan 05 '18 at 21:09
  • @ZaytsevDmitry great, that post did help a lot – Dora Jan 05 '18 at 22:07
  • @Shiva thx for that url, but Zaytsev's is more closer to what I needed – Dora Jan 05 '18 at 22:07
  • @Tsuna I believe I got it working and it's not middleware that is needed, only need to add extra variable for settings.py – Dora Jan 05 '18 at 22:08

0 Answers0