Cov txheej txheem:

Kuv puas tuaj yeem siv MySQL nrog Django?
Kuv puas tuaj yeem siv MySQL nrog Django?

Video: Kuv puas tuaj yeem siv MySQL nrog Django?

Video: Kuv puas tuaj yeem siv MySQL nrog Django?
Video: Sua Vaj - Kuv Ua Tus Phem 2024, Hlis ntuj nqeg
Anonim

Nyob rau hauv thiaj li yuav siv MySQL nrog peb qhov project, peb yuav xav tau Python 3 database connector tsev qiv ntawv sib haum nrog Django . Yog li, peb yuav nruab lub database connector, mysqlclient, uas yog ib tug forked version ntawm MySQLdb. Koj ua tau nruab python3-dev los ntawm kev khiav cov lus txib hauv qab no: sudo apt-mus nruab python3-dev.

Yog li ntawd, cov ntaub ntawv twg yog qhov zoo tshaj plaws rau Django?

4 Teb. Yog tias koj yuav siv a kev sib txheeb database , qhov nrov tshaj plaws hauv zej zog Django zoo li PostgreSQL. Nws yog kuv tus kheej nyiam. Tab sis, MongoDB zoo li tau txais txiaj ntsig zoo hauv Python / Django zej zog ib yam nkaus (Kuv tsis tau ua ib txoj haujlwm nrog nws, txawm li cas los xij).

Ib yam li ntawd, Django txuas rau SQLite database li cas? Ntawm no yog cov kauj ruam.

  1. Nruab SQLite 3 [email tiv thaiv]: ~ $ sudo apt-tau nruab sqlite3.
  2. Kho kom raug settings.py.
  3. Tsim Django cov ntxhuav hauv cov ntaub ntawv.
  4. Ua tib zoo saib cov databases tsim [email tiv thaiv]:~/Web/mysite$ sqlite3 mydb SQLite version 3.4.2 Sau ".pab" rau cov lus qhia sqlite>.schema.

Tsis tas li ntawd, Django puas xav tau lub database?

Koj yuav tsum siv a database engine yog koj xav siv ib co nta ntawm django ua , zoo li kev sib tham, piv txwv li. Yog koj ua tsis yog xav tau cov, tsuas yog tshem tawm ntawm cov chav kawm nruab nrab.

Kuv yuav teeb tsa MySQL database li cas?

Txhawm rau nruab MySQL database:

  1. Nruab MySQL database server nkaus xwb thiab xaiv Server Tshuab raws li hom kev teeb tsa.
  2. Xaiv qhov kev xaiv los khiav MySQL raws li kev pabcuam.
  3. Tua tawm MySQL Command-Line Client. Txhawm rau tso tus neeg siv khoom, nkag mus rau cov lus txib hauv qab no hauv Command Prompt window: mysql -u root -p.

Pom zoo: