Member-only story
Django SQLite to PostgreSQL database migration
Django SQLite to PostgreSQL database migration
Hi All, in this article I'm going to show you how to move data from SQLite to Postgres.
Steps are
- Take SQLite whole DB dumpdata fixture backup
- Create Postgres DB with user and password
- Change settings.py
- import fixture using loaddata
1. Take SQLite whole DB dumpdata fixture backup.
first, you need to take the backup of the whole DB using the below command
python manage.py dumpdata > whole.json
in this command, some users prefer to use the natural foreign key and primary key but I won't suggest using the bellow command until you get an error while restoring(loaddata) data to Postgres
python manage.py dumpdata — natural-foreign — natural-primary > whole.json
this commands will generate the whole.json in the root of your projects, this means you generated the dumpdata from SQLite in JSON fixture format.
2. Create Postgres DB with user and password.
in this step, you need to install Postgres on your OS like Ubuntu or Mac (google)…