로컬에서 작업을 진행할 것입니다. 작업을 시작하기에 앞서 Python이 설치가 되어야 작업이 진행될 수 있습니다. Python이 이미 설치된 분들은 넘어가셔도 됩니다.
구글에 Python을 검색하셔서 Python을 다운로드 받으시면 됩니다.

그리고 에디터의 경우에는 PyCharm을 사용하도록 하겠습니다. 인터프리터와 가상환경 구현이 굉장히 편하기 때문에 PyCharm을 이용합니다.


설치가 완료되었다면 PyCharm을 실행하고 새 프로젝트를 생성하겠습니다.

인터프리터 부분에서 간단한 설정을 적용합니다. 환경이 Virtualenv로 되어있는지 확인하고, Python 인터프리터가 3.8 버전으로 잘 되어 있는지 확인해주면 됩니다. 다 확인했다면 Create 버튼을 눌러줍니다.


생성이 되었다면 터미널을 열어 다음 명령어들을 입력합니다.
pip install django==2.1 django-admin startproject config. python manage.py migrate python manage.py runserver
잘 실행되었다면 아래와 같은 결과가 나타나실 겁니다. 이후에 링크를 눌러서 클릭해주시면 됩니다.

Django 세팅이 완료되었으니 AWS 사이트에 들어가 보도록 하겠습니다. 회원가입 과정은 생략하도록 하겠습니다. 회원가입이 완료되었다면 먼저 로그인을 하시면 됩니다.

서비스 목록을 내리시다 보면 RDS를 발견하실 수 있습니다.


먼저 파라미터 그룹을 생성해 줍니다.

파라미터 그룹 패밀리를 mysql5.7로 설정해주도록 하겠습니다.

파라미터 그룹이 생성되었다면 간단한 수정을 진행해주도록 하겠습니다.
rdstest로 들어가셔서 character을 검색합니다. 그리고 값에서 utf8로 변경한 경우 모두 utf8로 수정했습니다.


파라미터 설정이 완료되었다면 데이터베이스 부분으로 넘어가서 데이터베이스 생성 버튼을 클릭해야 합니다.

아래와 같이 MySQL로 설정하고 5.7.23 버전으로 진행합니다.


테스트를 위해서 프리티어를 사용하겠습니다.

비밀번호는 123456789로 설정하였습니다.

비용청구가 될 수 있기 때문에 스토리지 자동 조정 활성화를 체크합니다.

퍼블릭 엑세스 가능을 허용하여 테스트를 할 수 있게 합니다.


자동 백업 활성화를 체크 해제합니다. 혹시 체크되어있다면 비용이 청구될 수 있습니다.


이번에는 보안 그룹을 수정해보도록 하겠습니다. rdtest를 클릭하시고 보안 그룹을 클릭해줍니다.



이렇게 규칙을 설정해서 추가하고 저장을 누르고 PyCharm으로 돌아가서 서버를 닫습니다.
clear
명령어를 입력하여 PyMySQL을 설치하겠습니다.
pip install pymysql
settings.py
를 수정해주도록 하겠습니다.파일명 :
settings.py
import pymysql pymysql.install_as_MySQLdb(); ... DATABASES = { 'default' : { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'rdstest', 'USER': 'rdstest', 'PASSWORD': '123456789', 'HOST' : '', 'PORT': '3306', } }
호스트 안에는 데이터베이스가 모두 생성되고 보이는 엔드포인트 값을 넣어주시면 됩니다.

그리고 최종적으로 아래와 같은 결과가 출력된다면 RDS 연결이 완료된 것입니다.
python manage.py migrate
