added DJ-pool

This commit is contained in:
Mohamed Nouffer
2023-05-03 19:13:24 +05:30
parent 0f7cf18ecb
commit e71d2e6f04
2 changed files with 8 additions and 19 deletions

View File

@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
from pathlib import Path from pathlib import Path
import environ import environ
import os import os
import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@ -89,26 +90,14 @@ WSGI_APPLICATION = 'config.wsgi.application'
# Database # Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'dj_db_conn_pool.backends.postgresql',
'NAME': env("POSTGRES_DBNAME"),
'USER': env("POSTGRES_USER"),
'PASSWORD': env("POSTGRES_PASS"),
'HOST': env("PG_HOST"),
'PORT': env("PG_PORT")
}
}
DATABASES = { DATABASES = {
'default': { 'default': dj_database_url.config(
'POOL_OPTIONS' : { default=f'postgis://{env("POSTGRES_USER")}:{env("POSTGRES_PASS")}@{env("PG_HOST")}:{env("PG_PORT")}/{env("POSTGRES_DBNAME")}',
'POOL_SIZE': 200, conn_max_age=600,
'MAX_OVERFLOW': 10, conn_health_checks=True,
'RECYCLE': 24 * 60 * 60 )
} }
}
}
# Password validation # Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

View File

@ -64,4 +64,4 @@ urllib3==1.26.7
django-extra-fields==3.0.2 django-extra-fields==3.0.2
django-phonenumber-field==6.1.0 django-phonenumber-field==6.1.0
django-rest-knox==4.2.0 django-rest-knox==4.2.0
django-db-connection-pool[postgresql] dj-database-url==2.0.0