Django Sqlite3 Database migration to MySQL

Source: Internet
Author: User

Two URLs are integrated.

1,http://www.phodal.com/blog/django-mezzanine-sqlite3-migrate-mysql/

2,http://www.ziqiangxuetang.com/django/django-data-migration.html

A. Create a Slave database first

DATABASES = {    "default": {        "ENGINE":"Django.db.backends.sqlite3",        "NAME":"dev.db",        "USER":"",        "PASSWORD":"",        "HOST":"",        "PORT":"",    },    "slave": {        "ENGINE":"Django.db.backends.mysql",        "NAME":"Phodal",        "USER":"Root",        "PASSWORD":"",        "HOST":"",        "PORT":"",    },}

B. Then, create an empty database in MySQL and get the table results from the main library from the library:

CREATE DATABASE phodal CHARACTER SET UTF8 COLLATE utf8_general_ci;

Python./manage.py syncdb--database Slave

C. Make sure that the SQL procedure statement for each app is generated, and if not, run the following statement:

Python manage.py makemigrations FAT

D. Export the data from the SQLite Master library:

Python manage.py dumpdata > Mysite_all_data.json

E. Switch the main library and the setting.py settings from the library, set MySQL as the primary library, and import the data.

Python manage.py loaddata Mysite_all_data.json

  If the static file Css.js points to an error, run:

Python manage.py collectstatic

Then put the static text repair to the appropriate position.

Django Sqlite3 Database migration to MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.