μ λ μλμ½λ€λ‘ νλλ° μλμ²λΌ μΌμΌ νμ
λ λμ¬ (μ½λλ μμμ μ°Ύμ보μλκ² λΉ λ₯Όμ§λ γ
γ
)
1) κ°μνκ²½ μμ± λ° μ€ν
% python -m venv κ°μνκ²½μ΄λ¦ --python=python3.8
% cd κ°μνκ²½μ΄λ¦/Scripts
% activate.bat
% cd λ³Έ νλ‘μ νΈ κ²½λ‘
2) μ΅μμ ν΄λμ requirements.txtλ‘ νμν package μ€μΉ
% pip install requirements.txt
1) mariaDB ν°λ―Έλμμ database μμ±
MariaDB [(none)]> create database λ°μ΄ν°λ² μ΄μ€μ΄λ¦;
MariaDB [(none)]> use λ°μ΄ν°λ² μ΄μ€μ΄λ¦;
Database changed
MariaDB [sbc]> grant all privileges on λ°μ΄ν°λ² μ΄μ€μ΄λ¦.* to 'root'@'%' identified by 'μ΅μ΄μ€νμμμ±νλΉλ°λ²νΈ';
2) settings.pyμμ μμ μ mariaDB μ λ³΄λ‘ μμ ν΄μ€λλ€
DATABASES = {
'default' : {
'ENGINE' : 'django.db.backends.mysql' ,
'NAME' : 'λ°μ΄ν°λ² μ΄μ€μ΄λ¦' ,
'USER' : 'root' ,
'PASSWORD' : 'μ΅μ΄μ€νμμμ±νλΉλ°λ²νΈ' ,
'HOST' : '127.0.0.1' ,
'PORT' : '3306'
}
}
3. μμ
λ°μ΄ν° DBμ μ μ₯νκΈ°
μ κ±°λ μ½λμ λ§κ² μμ λ νμΌμ΄λΌ μ¬λ¬λΆ sheetμμλ λ€λ₯Ό μ μμ΄μ©
κ·ΈλΌ μ°λ½μ£ΌμΈμ© ~~~ μλ μ κ±Έλ‘ κ·Έλ₯ λλ €μ£ΌμΈμ~~~
1) ν°λ―Έλμμ μ€ν νμ tableμ΄ μμ±λλμ§ νμΈν΄μ£ΌμΈμ ~
% python manage.py makemigrations BootCamp
% python manage.py migrate
conn = pymysql .connect (host = '127.0.0.1' , user = 'root' , password = 'μ΅μ΄μ€νμμμ±νλΉλ°λ²νΈ' , db = 'sbc' )
curs = conn .cursor (pymysql .cursors .DictCursor )
3) μμ
νμΌ DBμ μ μ₯νκΈ°
% cd BootCamp
% python BootCampUpdate.py
createsuperuser μνΌλνΌκΆνμ κ°μ§ admin κ³μ μ μμ±ν΄μ£ΌμΈμ©
μλ² κ΅¬λ νμ admin νμ΄μ§ κ°μ κ³μ μ λ§λ€μ΄μ‘λ νμΈν΄λ³΄μΈμ₯
% cd sbc_api
% python manage.py createsuperuser
% python manage.py runserver
requirement.txt νμΌμ΄ κ³μ μλ¬κ° λλ©΄ μ΄ νμΌλ‘ μμ ν΄μ install ν΄μ£ΌμΈμ!
requirements.txt