diff --git a/django/db/utils.py b/django/db/utils.py index 7ef62ae5a2..5459fc9a33 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -166,7 +166,7 @@ class ConnectionHandler(BaseConnectionHandler): where no settings is provided. """ try: - conn = self.databases[alias] + conn = self.settings[alias] except KeyError: raise self.exception_class(f"The connection '{alias}' doesn't exist.") @@ -187,7 +187,7 @@ class ConnectionHandler(BaseConnectionHandler): Make sure the test settings are available in the 'TEST' sub-dictionary. """ try: - conn = self.databases[alias] + conn = self.settings[alias] except KeyError: raise self.exception_class(f"The connection '{alias}' doesn't exist.") @@ -205,7 +205,7 @@ class ConnectionHandler(BaseConnectionHandler): def create_connection(self, alias): self.ensure_defaults(alias) self.prepare_test_settings(alias) - db = self.databases[alias] + db = self.settings[alias] backend = load_backend(db["ENGINE"]) return backend.DatabaseWrapper(db, alias) diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py index 6ff3a33fc4..0145483f6b 100644 --- a/tests/gis_tests/inspectapp/tests.py +++ b/tests/gis_tests/inspectapp/tests.py @@ -204,7 +204,7 @@ def get_ogr_db_string(): GDAL will create its own connection to the database, so we re-use the connection settings from the Django test. """ - db = connections.databases["default"] + db = connections.settings["default"] # Map from the django backend into the OGR driver name and database identifier # https://gdal.org/drivers/vector/