Migration PostgreSQL from SQLite: dump data for back up and restore

We will cover topics such as dumping data from an SQLite3 database, connecting to a PostgreSQL database, removing content types from the Django database, and loading data into a PostgreSQL database. These snippets and instructions will provide you with valuable insights and practical solutions for handling data in your Django projects.

1. Dump data from sqlite3
python dumpdata  --exclude contenttypes > x.json

2. Connect to postgres & verify by runserver & Migrate
python migrate --run-syncdb

3. Remove conent type from django database before load data
python shell
from django.contrib.contenttypes.models import ContentType

4. Load data to Postgresql
python loaddata x.json

Published @ Aug 2023