prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Ensure that only Postgres databases are connected
  **Problem**
  <!-- Please provide a clear and concise description of the problem that this feature request is designed to solve.-->
  Django and SQLAlchemy both support multiple database systems, but we're presuming that the user is only connected Postgres databases. This could lead to bugs if the user connects a MySQL or other database.
  
  **Proposed solution**
  <!-- A clear and concise description of your proposed solution or feature. -->
  We should check to make sure that we're only managing Postgres databases and throw an error if another database system is connected.
  
  I'm not sure if matters what database is used for the Django database, since we're only using standard Django functionality there, but we should definitely check the Mathesar managed databases.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `config/settings.py`
  Content:
  ```
  1 """
  2 Django settings for config project.
  3 
  4 Generated by 'django-admin startproject' using Django 3.1.7.
  5 
  6 For more information on this file, see
  7 https://docs.djangoproject.com/en/3.1/topics/settings/
  8 
  9 For the full list of settings and their values, see
  10 https://docs.djangoproject.com/en/3.1/ref/settings/
  11 """
  12 
  13 import os
  14 from pathlib import Path
  15 
  16 from decouple import Csv, config as decouple_config
  17 from dj_database_url import parse as db_url
  18 
  19 
  20 # We use a 'tuple' with pipes as delimiters as decople naively splits the global
  21 # variables on commas when casting to Csv()
  22 def pipe_delim(pipe_string):
  23     # Remove opening and closing brackets
  24     pipe_string = pipe_string[1:-1]
  25     # Split on pipe delim
  26     return pipe_string.split("|")
  27 
  28 
  29 # Build paths inside the project like this: BASE_DIR / 'subdir'.
  30 BASE_DIR = Path(__file__).resolve().parent.parent
  31 
  32 # Application definition
  33 
  34 INSTALLED_APPS = [
  35     "django.contrib.admin",
  36     "django.contrib.auth",
  37     "django.contrib.contenttypes",
  38     "django.contrib.sessions",
  39     "django.contrib.messages",
  40     "django.contrib.staticfiles",
  41     "rest_framework",
  42     "django_filters",
  43     "django_property_filter",
  44     "mathesar",
  45 ]
  46 
  47 MIDDLEWARE = [
  48     "django.middleware.security.SecurityMiddleware",
  49     "django.contrib.sessions.middleware.SessionMiddleware",
  50     "django.middleware.common.CommonMiddleware",
  51     "django.middleware.csrf.CsrfViewMiddleware",
  52     "django.contrib.auth.middleware.AuthenticationMiddleware",
  53     "django.contrib.messages.middleware.MessageMiddleware",
  54     "django.middleware.clickjacking.XFrameOptionsMiddleware",
  55 ]
  56 
  57 ROOT_URLCONF = "config.urls"
  58 
  59 TEMPLATES = [
  60     {
  61         "BACKEND": "django.template.backends.django.DjangoTemplates",
  62         "DIRS": [],
  63         "APP_DIRS": True,
  64         "OPTIONS": {
  65             "context_processors": [
  66                 "config.context_processors.get_settings",
  67                 "django.template.context_processors.debug",
  68                 "django.template.context_processors.request",
  69                 "django.contrib.auth.context_processors.auth",
  70                 "django.contrib.messages.context_processors.messages",
  71             ],
  72         },
  73     },
  74 ]
  75 
  76 WSGI_APPLICATION = "config.wsgi.application"
  77 
  78 # Database
  79 # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
  80 
  81 # TODO: Add to documentation that database keys should not be than 128 characters.
  82 
  83 # MATHESAR_DATABASES should be of the form '({db_name}|{db_url}), ({db_name}|{db_url})'
  84 # See pipe_delim above for why we use pipes as delimiters
  85 DATABASES = {
  86     db_key: db_url(url_string)
  87     for db_key, url_string in decouple_config('MATHESAR_DATABASES', cast=Csv(pipe_delim))
  88 }
  89 DATABASES[decouple_config('DJANGO_DATABASE_KEY')] = decouple_config('DJANGO_DATABASE_URL', cast=db_url)
  90 
  91 # pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'
  92 # and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']
  93 if decouple_config('TEST', default=False, cast=bool):
  94     for db_key, _ in decouple_config('MATHESAR_DATABASES', cast=Csv(pipe_delim)):
  95         DATABASES[db_key]['TEST'] = {'NAME': DATABASES[db_key]['NAME']}
  96 
  97 
  98 # Quick-start development settings - unsuitable for production
  99 # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
  100 
  101 # SECURITY WARNING: keep the secret key used in production secret!
  102 SECRET_KEY = decouple_config('SECRET_KEY')
  103 
  104 # SECURITY WARNING: don't run with debug turned on in production!
  105 DEBUG = decouple_config('DEBUG', default=False, cast=bool)
  106 
  107 ALLOWED_HOSTS = decouple_config('ALLOWED_HOSTS', cast=Csv())
  108 
  109 # Password validation
  110 # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
  111 
  112 AUTH_PASSWORD_VALIDATORS = [
  113     {
  114         "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  115     },
  116     {
  117         "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
  118     },
  119     {
  120         "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
  121     },
  122     {
  123         "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
  124     },
  125 ]
  126 
  127 
  128 # Internationalization
  129 # https://docs.djangoproject.com/en/3.1/topics/i18n/
  130 
  131 LANGUAGE_CODE = "en-us"
  132 
  133 TIME_ZONE = "UTC"
  134 
  135 USE_I18N = True
  136 
  137 USE_L10N = True
  138 
  139 USE_TZ = True
  140 
  141 
  142 # Static files (CSS, JavaScript, Images)
  143 # https://docs.djangoproject.com/en/3.1/howto/static-files/
  144 
  145 STATIC_URL = "/static/"
  146 
  147 CLIENT_DEV_URL = "http://localhost:3000"
  148 
  149 
  150 # Media files (uploaded by the user)
  151 
  152 MEDIA_ROOT = os.path.join(BASE_DIR, '.media/')
  153 
  154 MEDIA_URL = "/media/"
  155
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/config/settings.py b/config/settings.py
  --- a/config/settings.py
  +++ b/config/settings.py
  @@ -88,6 +88,15 @@
   }
   DATABASES[decouple_config('DJANGO_DATABASE_KEY')] = decouple_config('DJANGO_DATABASE_URL', cast=db_url)
   
  +for db_key, db_dict in DATABASES.items():
  +    # Engine can be '.postgresql' or '.postgresql_psycopg2'
  +    if not db_dict['ENGINE'].startswith('django.db.backends.postgresql'):
  +        raise ValueError(
  +            f"{db_key} is not a PostgreSQL database. "
  +            f"{db_dict['ENGINE']} found for {db_key}'s engine."
  +        )
  +
  +
   # pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'
   # and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']
   if decouple_config('TEST', default=False, cast=bool):
  
verification_info: {"golden_diff": "diff --git a/config/settings.py b/config/settings.py\n--- a/config/settings.py\n+++ b/config/settings.py\n@@ -88,6 +88,15 @@\n }\n DATABASES[decouple_config('DJANGO_DATABASE_KEY')] = decouple_config('DJANGO_DATABASE_URL', cast=db_url)\n \n+for db_key, db_dict in DATABASES.items():\n+    # Engine can be '.postgresql' or '.postgresql_psycopg2'\n+    if not db_dict['ENGINE'].startswith('django.db.backends.postgresql'):\n+        raise ValueError(\n+            f\"{db_key} is not a PostgreSQL database. \"\n+            f\"{db_dict['ENGINE']} found for {db_key}'s engine.\"\n+        )\n+\n+\n # pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'\n # and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']\n if decouple_config('TEST', default=False, cast=bool):\n", "issue": "Ensure that only Postgres databases are connected\n**Problem**\r\n<!-- Please provide a clear and concise description of the problem that this feature request is designed to solve.-->\r\nDjango and SQLAlchemy both support multiple database systems, but we're presuming that the user is only connected Postgres databases. This could lead to bugs if the user connects a MySQL or other database.\r\n\r\n**Proposed solution**\r\n<!-- A clear and concise description of your proposed solution or feature. -->\r\nWe should check to make sure that we're only managing Postgres databases and throw an error if another database system is connected.\r\n\r\nI'm not sure if matters what database is used for the Django database, since we're only using standard Django functionality there, but we should definitely check the Mathesar managed databases.\n", "before_files": [{"content": "\"\"\"\nDjango settings for config project.\n\nGenerated by 'django-admin startproject' using Django 3.1.7.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/3.1/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/3.1/ref/settings/\n\"\"\"\n\nimport os\nfrom pathlib import Path\n\nfrom decouple import Csv, config as decouple_config\nfrom dj_database_url import parse as db_url\n\n\n# We use a 'tuple' with pipes as delimiters as decople naively splits the global\n# variables on commas when casting to Csv()\ndef pipe_delim(pipe_string):\n    # Remove opening and closing brackets\n    pipe_string = pipe_string[1:-1]\n    # Split on pipe delim\n    return pipe_string.split(\"|\")\n\n\n# Build paths inside the project like this: BASE_DIR / 'subdir'.\nBASE_DIR = Path(__file__).resolve().parent.parent\n\n# Application definition\n\nINSTALLED_APPS = [\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \"rest_framework\",\n    \"django_filters\",\n    \"django_property_filter\",\n    \"mathesar\",\n]\n\nMIDDLEWARE = [\n    \"django.middleware.security.SecurityMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nROOT_URLCONF = \"config.urls\"\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [],\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"config.context_processors.get_settings\",\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = \"config.wsgi.application\"\n\n# Database\n# https://docs.djangoproject.com/en/3.1/ref/settings/#databases\n\n# TODO: Add to documentation that database keys should not be than 128 characters.\n\n# MATHESAR_DATABASES should be of the form '({db_name}|{db_url}), ({db_name}|{db_url})'\n# See pipe_delim above for why we use pipes as delimiters\nDATABASES = {\n    db_key: db_url(url_string)\n    for db_key, url_string in decouple_config('MATHESAR_DATABASES', cast=Csv(pipe_delim))\n}\nDATABASES[decouple_config('DJANGO_DATABASE_KEY')] = decouple_config('DJANGO_DATABASE_URL', cast=db_url)\n\n# pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'\n# and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']\nif decouple_config('TEST', default=False, cast=bool):\n    for db_key, _ in decouple_config('MATHESAR_DATABASES', cast=Csv(pipe_delim)):\n        DATABASES[db_key]['TEST'] = {'NAME': DATABASES[db_key]['NAME']}\n\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = decouple_config('SECRET_KEY')\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = decouple_config('DEBUG', default=False, cast=bool)\n\nALLOWED_HOSTS = decouple_config('ALLOWED_HOSTS', cast=Csv())\n\n# Password validation\n# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",\n    },\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/3.1/topics/i18n/\n\nLANGUAGE_CODE = \"en-us\"\n\nTIME_ZONE = \"UTC\"\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/3.1/howto/static-files/\n\nSTATIC_URL = \"/static/\"\n\nCLIENT_DEV_URL = \"http://localhost:3000\"\n\n\n# Media files (uploaded by the user)\n\nMEDIA_ROOT = os.path.join(BASE_DIR, '.media/')\n\nMEDIA_URL = \"/media/\"\n", "path": "config/settings.py"}], "after_files": [{"content": "\"\"\"\nDjango settings for config project.\n\nGenerated by 'django-admin startproject' using Django 3.1.7.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/3.1/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/3.1/ref/settings/\n\"\"\"\n\nimport os\nfrom pathlib import Path\n\nfrom decouple import Csv, config as decouple_config\nfrom dj_database_url import parse as db_url\n\n\n# We use a 'tuple' with pipes as delimiters as decople naively splits the global\n# variables on commas when casting to Csv()\ndef pipe_delim(pipe_string):\n    # Remove opening and closing brackets\n    pipe_string = pipe_string[1:-1]\n    # Split on pipe delim\n    return pipe_string.split(\"|\")\n\n\n# Build paths inside the project like this: BASE_DIR / 'subdir'.\nBASE_DIR = Path(__file__).resolve().parent.parent\n\n# Application definition\n\nINSTALLED_APPS = [\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \"rest_framework\",\n    \"django_filters\",\n    \"django_property_filter\",\n    \"mathesar\",\n]\n\nMIDDLEWARE = [\n    \"django.middleware.security.SecurityMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n]\n\nROOT_URLCONF = \"config.urls\"\n\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [],\n        \"APP_DIRS\": True,\n        \"OPTIONS\": {\n            \"context_processors\": [\n                \"config.context_processors.get_settings\",\n                \"django.template.context_processors.debug\",\n                \"django.template.context_processors.request\",\n                \"django.contrib.auth.context_processors.auth\",\n                \"django.contrib.messages.context_processors.messages\",\n            ],\n        },\n    },\n]\n\nWSGI_APPLICATION = \"config.wsgi.application\"\n\n# Database\n# https://docs.djangoproject.com/en/3.1/ref/settings/#databases\n\n# TODO: Add to documentation that database keys should not be than 128 characters.\n\n# MATHESAR_DATABASES should be of the form '({db_name}|{db_url}), ({db_name}|{db_url})'\n# See pipe_delim above for why we use pipes as delimiters\nDATABASES = {\n    db_key: db_url(url_string)\n    for db_key, url_string in decouple_config('MATHESAR_DATABASES', cast=Csv(pipe_delim))\n}\nDATABASES[decouple_config('DJANGO_DATABASE_KEY')] = decouple_config('DJANGO_DATABASE_URL', cast=db_url)\n\nfor db_key, db_dict in DATABASES.items():\n    # Engine can be '.postgresql' or '.postgresql_psycopg2'\n    if not db_dict['ENGINE'].startswith('django.db.backends.postgresql'):\n        raise ValueError(\n            f\"{db_key} is not a PostgreSQL database. \"\n            f\"{db_dict['ENGINE']} found for {db_key}'s engine.\"\n        )\n\n\n# pytest-django will create a new database named 'test_{DATABASES[table_db]['NAME']}'\n# and use it for our API tests if we don't specify DATABASES[table_db]['TEST']['NAME']\nif decouple_config('TEST', default=False, cast=bool):\n    for db_key, _ in decouple_config('MATHESAR_DATABASES', cast=Csv(pipe_delim)):\n        DATABASES[db_key]['TEST'] = {'NAME': DATABASES[db_key]['NAME']}\n\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the secret key used in production secret!\nSECRET_KEY = decouple_config('SECRET_KEY')\n\n# SECURITY WARNING: don't run with debug turned on in production!\nDEBUG = decouple_config('DEBUG', default=False, cast=bool)\n\nALLOWED_HOSTS = decouple_config('ALLOWED_HOSTS', cast=Csv())\n\n# Password validation\n# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators\n\nAUTH_PASSWORD_VALIDATORS = [\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.UserAttributeSimilarityValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.MinimumLengthValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.CommonPasswordValidator\",\n    },\n    {\n        \"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",\n    },\n]\n\n\n# Internationalization\n# https://docs.djangoproject.com/en/3.1/topics/i18n/\n\nLANGUAGE_CODE = \"en-us\"\n\nTIME_ZONE = \"UTC\"\n\nUSE_I18N = True\n\nUSE_L10N = True\n\nUSE_TZ = True\n\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/3.1/howto/static-files/\n\nSTATIC_URL = \"/static/\"\n\nCLIENT_DEV_URL = \"http://localhost:3000\"\n\n\n# Media files (uploaded by the user)\n\nMEDIA_ROOT = os.path.join(BASE_DIR, '.media/')\n\nMEDIA_URL = \"/media/\"\n", "path": "config/settings.py"}]}