SQLite to PostgreSQL - adityaskarnik/expense_app GitHub Wiki
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main # for ubuntu 18.04
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
apt-get install postgresql-10
sudo vi /etc/postgresql/10/main/pg_hba.conf
Change this line (md5 to trust):
# Database administrative login by Unix domain socket
local all postgres trust
Run this command to apply the changes
sudo service postgresql restart
sudo -u postgres createuser <user_name> # create user
sudo -u postgres createdb <db_name> # create new database
# create a password to the user
sudo -u postgres psql
alter user expense with encrypted password '<password>';
python manage.py makemigrations
python manage.py migrate
-
Using csv, go here
-
Export using application manage .py
python manage.py dumpdata > dump_sqlite.json
To convert your model changes to python code and apply them:
python manage.py makemigrations python manage.py migrate
Finally:
python manage.py loaddata dump_sqlite.json