-
Notifications
You must be signed in to change notification settings - Fork 2
/
my_settings.py
60 lines (55 loc) · 1.63 KB
/
my_settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
### mysql setting
import os, json
from pathlib import Path
from django.core.exceptions import ImproperlyConfigured
BASE_DIR = Path(__file__).resolve().parent
secret_file = os.path.join(BASE_DIR, 'secrets.json') # secrets.json 파일 위치를 명시
with open(secret_file) as f:
secrets = json.loads(f.read())
def get_secret(setting, secrets=secrets):
try:
return secrets[setting]
except KeyError:
error_msg = "Set the {} environment variable".format(setting)
raise ImproperlyConfigured(error_msg)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'chunghaha',
'USER': 'admin',
'PASSWORD': get_secret("DB_PASSWORD"),
'HOST': get_secret("DB_HOST"),
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
'charset': 'utf8mb4',
'use_unicode': True,
},
},
'chunghaha' : {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'chunghaha',
'USER': 'admin',
'PASSWORD': get_secret("DB_PASSWORD"),
'HOST': get_secret("DB_HOST"),
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
'charset': 'utf8mb4',
'use_unicode': True,
},
},
'chunghaha-dev': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'chunghaha',
'USER': 'admin',
'PASSWORD': get_secret("DB_PASSWORD"),
'HOST': get_secret("DB_HOST"),
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
'charset': 'utf8mb4',
'use_unicode': True,
},
},
}