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
import environ
import os
import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -89,25 +90,13 @@ WSGI_APPLICATION = 'config.wsgi.application'
# Database
# 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 = {
'default': {
'POOL_OPTIONS' : {
'POOL_SIZE': 200,
'MAX_OVERFLOW': 10,
'RECYCLE': 24 * 60 * 60
}
}
'default': dj_database_url.config(
default=f'postgis://{env("POSTGRES_USER")}:{env("POSTGRES_PASS")}@{env("PG_HOST")}:{env("PG_PORT")}/{env("POSTGRES_DBNAME")}',
conn_max_age=600,
conn_health_checks=True,
)
}
# Password validation

View File

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