From 681cd67ef7f5303130c03ecd133d7bc3498277c0 Mon Sep 17 00:00:00 2001 From: Xavier Frankline Odhiambo <49587182+thepsalmist@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:53:17 +0300 Subject: [PATCH] Revert "Fix database routers (#125)" This reverts commit 9464c36443fce910739f1d2a32af1344a0eb1e5b. --- sensorsafrica/router.py | 2 +- sensorsafrica/settings.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sensorsafrica/router.py b/sensorsafrica/router.py index cdd0670..810397e 100644 --- a/sensorsafrica/router.py +++ b/sensorsafrica/router.py @@ -3,7 +3,7 @@ from django.conf import settings class ReplicaRouter: - read_replicas = list(settings.DATABASES.keys()) + read_replicas = settings.READ_DATABASE_URLS def db_for_read(self, model, **hints): return random.choice(self.read_replicas) diff --git a/sensorsafrica/settings.py b/sensorsafrica/settings.py index fcbbf17..bb72a6c 100644 --- a/sensorsafrica/settings.py +++ b/sensorsafrica/settings.py @@ -113,12 +113,12 @@ DATABASES = {"default": dj_database_url.parse(DATABASE_URL), } -READ_DATABASE_URLS = os.getenv("SENSORSAFRICA_READ_DATABASE_URLS", DATABASE_URL).split(",") +# READ_DATABASE_URLS = os.getenv("SENSORSAFRICA_READ_DATABASE_URLS", DATABASE_URL).split(",") -for index, read_database_url in enumerate(READ_DATABASE_URLS,start=1): - DATABASES[f"read_replica_{index}"] = dj_database_url.parse(read_database_url) +# for index, read_database_url in enumerate(READ_DATABASE_URLS,start=1): +# DATABASES[f"read_replica_{index}"] = dj_database_url.parse(read_database_url) -DATABASE_ROUTERS = ["sensorsafrica.router.ReplicaRouter", ] +# DATABASE_ROUTERS = ["sensorsafrica.router.ReplicaRouter", ] # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators