arrow_back

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 manage.py dumpdata  --exclude contenttypes > x.json

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

3. Remove conent type from django database before load data
python manage.py shell
from django.contrib.contenttypes.models import ContentType
ContentType.objects.all().delete()

4. Load data to Postgresql
python manage.py loaddata x.json


Published @ Aug 2023