Transitioning from SQLite3 to PostgreSQL

This Site

June 5, 2019

After having some issues with the python virtual environment and Sqlite3 dependencies when configuring my django project with apache, I decided to migrate my blog database to postgresql. I have heard PostgreSQL is more malleable and commonly used. While it was nice to have the built-in functionality of SQLite3 on my personal machine, using PostgreSQL will allow me to customize my database interaction.

Step by Step to PostgreSQL??

I wish I would have actually done this the right way so I had some sort of "steps to migrate your Django Database to PostgreSQL" part of this post. However, the road wasn't as clear as certain step-by-steps on the internet led me to believe. While I got django configured with a unique PostgreSQL user account and database, I was unable to make use of Django's datadump and loaddata commands. The only reason this method didn't work is because my datadump.json file from my SQLite3 database somehow got overwritten by an empty JSON string, when at first it was an actual datadump of the blog database. I ended up copy-pasting the markdown content from blog posts on my personal laptop and into the admin page running on my virtual private server. If I understand correctly, the proper way to dump and load Django database data is:

  1. $ python manage.py dumpdata > db.json
  2. Change around settings.py for PostgreSQL user / database /port 5432.
  3. Make Sure Postgres Unix user pg_hba.conf file allows for md5 password facilitated communication from any host, as well as a line specifically for your host: / databaseName / IP address / method (md5).
  4. $ sudo systemctl restart postgresql
  5. $ python manage.py runserver bbissey.com:8000 to check that the database can be accessed and/or added to using your administration page. You could also check the new database's functionality by running a population script.

Dates Field

I'm wondering if I can have access over the date field of each blog post, and give the system older dates even if the posts were just recently made. I could use this function for older posts before the PostgreSQL migration. However, this would mean I'd be changing a field that isn't necessarily "meant" to be changed.

Life Update

About to move into a new house with some good friends. It will become a haven for new ideas and intellectual challenges. Hoping to stay up with this website and other programming projects during the move!