Setting-Up PostgreSQL as Your Django Database (for Mac OS)
PostgreSQL is the database of choice for many Python developers. In fact, the team behind the Django framework for Python use PostgreSQL as their go-to database.
Installation: for Mac, just download the PostgreSQL app here at http://postgresapp.com/ and drag the icon to your applications folder and double-click to run it. Next, we need to map the PostgreSQL CLI tools to our PATH variable. Type this in your Terminal:
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
Fantastic. Close the Terminal window and open a new one for the changes to take effect.
(For Windows or Linux, you're going to need to go here for installation instructions: https://tutorial-extensions.djangogirls.org/en/optional_postgresql_installation/)
After that, type:
in your terminal to verify the installation was a success.
into the Terminal and your "#" icon should turn onto a "$", which means we're able to give commands to the database.
CREATE USER yournamegoes here;
(remember to type your name and the semi-colon. Get used to it now. After every command to the PostgreSQL database, we're going to need to type that semi-colon.
CREATE DATABASE yourdatabasename OWNER yournamegoes here;
You should get a confirmation your database was created. Ctrl-C will get you out of the database, but you can go back in any time by typing psql in your terminal.
Finally, from your terminal (but not in the database) type:
pip install psycopg2
This package enables Python to talk to our PostgreSQL database.
Alright, now you're rockin' n rollin'!
More posts to come about PostgreSQL and Django. Happy Coding!
I'd like to credit djangogirls.org for supplying the information contained in these instructions. I'd also like to thank my instructors at Code Platoon: Jon Young and Josh Aletto.