Django - switch from sqlite3 to mysql
Assuming that we have created Django project and there is an existing sqlite3 db, if not create a sqlite3 db and do the necessary migrations
Now in the command prompt
python3 manage.py dumpdata > datadump.json
This will export existing data into a json file
Create a new database in MySQL using the comand
CREATE DATABASE mydb
Update the settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydb',
'USER': 'admin',
'PASSWORD': 'admin',
'HOST':'localhost',
'PORT':'3306',
}
}
Then run makemigrations, migrate and finally
python3 manage.py loaddata datadump.json