How to migrate Django models from mysql to sqlite (or between any two database systems)?

后端 未结 4 1664
后悔当初
后悔当初 2021-02-06 04:42

I have a Django deployment in production that uses MySQL.

I would like to do further development with SQLite, so I would like to import my existing data to an SQLite dat

4条回答
  •  悲哀的现实
    2021-02-06 05:20

    use

    manage.py dumpdata > your_file.json
    

    to export your data from the production system (docs).

    Then move the file on the development system and run

    manage.py loaddata your_file.json
    

    You can also put the file in your_app/fixtures folder with name "initial_data.json" and it will be automatically loaded when you run "manage.py syncdb" (docs).

提交回复
热议问题