Skip to content

Commit

Permalink
PostgreSQL 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
MU-Software committed Jan 12, 2025
1 parent dcb4fa3 commit e4835c8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 20 deletions.
31 changes: 21 additions & 10 deletions pyconkr/settings-dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,28 @@
]

# RDS
DATABASES = {
"default": {
# "ENGINE": "mysql.connector.django",
"ENGINE": "django.db.backends.mysql",
"NAME": os.getenv("AWS_RDS_DATABASE"),
"USER": os.getenv("AWS_RDS_USER_ID"),
"PASSWORD": os.getenv("AWS_RDS_PW"),
"HOST": os.getenv("AWS_RDS_HOST"),
"PORT": os.getenv("AWS_RDS_PORT"),
if os.environ.get("AWS_PSQL_HOST"):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"HOST": os.getenv("AWS_PSQL_HOST"),
"PORT": os.getenv("AWS_PSQL_PORT"),
"NAME": os.getenv("AWS_PSQL_DATABASE"),
"USER": os.getenv("AWS_PSQL_USER_ID"),
"PASSWORD": os.getenv("AWS_PSQL_PW"),
}
}
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.getenv("AWS_RDS_DATABASE"),
"USER": os.getenv("AWS_RDS_USER_ID"),
"PASSWORD": os.getenv("AWS_RDS_PW"),
"HOST": os.getenv("AWS_RDS_HOST"),
"PORT": os.getenv("AWS_RDS_PORT"),
}
}
}

# django-storages: S3
del MEDIA_ROOT
Expand Down
31 changes: 21 additions & 10 deletions pyconkr/settings-prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,28 @@
]

# RDS
DATABASES = {
"default": {
# "ENGINE": "mysql.connector.django",
"ENGINE": "django.db.backends.mysql",
"NAME": os.getenv("AWS_RDS_DATABASE"),
"USER": os.getenv("AWS_RDS_USER_ID"),
"PASSWORD": os.getenv("AWS_RDS_PW"),
"HOST": os.getenv("AWS_RDS_HOST"),
"PORT": os.getenv("AWS_RDS_PORT"),
if os.environ.get("AWS_PSQL_HOST"):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"HOST": os.getenv("AWS_PSQL_HOST"),
"PORT": os.getenv("AWS_PSQL_PORT"),
"NAME": os.getenv("AWS_PSQL_DATABASE"),
"USER": os.getenv("AWS_PSQL_USER_ID"),
"PASSWORD": os.getenv("AWS_PSQL_PW"),
}
}
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.getenv("AWS_RDS_DATABASE"),
"USER": os.getenv("AWS_RDS_USER_ID"),
"PASSWORD": os.getenv("AWS_RDS_PW"),
"HOST": os.getenv("AWS_RDS_HOST"),
"PORT": os.getenv("AWS_RDS_PORT"),
}
}
}

# django-storages: S3
del MEDIA_ROOT
Expand Down
1 change: 1 addition & 0 deletions requirements-local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ django-cors-headers==3.14.0
requests==2.28.2
django-picklefield==3.1
setuptools==74.1.2
psycopg2-binary==2.9.10
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ django-cors-headers==3.14.0
requests==2.28.2
PyFunctional==1.4.3
pymysql==1.0.3
psycopg2-binary==2.9.10

0 comments on commit e4835c8

Please sign in to comment.