Note: This document is a work in progress. You can help improve it.

Setting up PostgreSQL

The database engine we will be using for our back-end work.

Mac Instructions

brew install postgresql pgcli

If you have used and configured pgcli you may skip the next instruction:

pgcli >/dev/null 2>&1
sed -i.bak "s/multiline_continuation_char = ''/multiline_continuation_char = '.'/g" ~/.config/pgcli/config
sed -i.bak "s/multi_line = False/multi_line = True/g" ~/.config/pgcli/config
sed -i.bak "s/enable_pager = True/enable_pager = False/g" ~/.config/pgcli/config
sed -i.bak "s/wider_completion_menu = False/wider_completion_menu = True/g" ~/.config/pgcli/config
sed -i.bak "s/syntax_style = default/syntax_style=native/g" ~/.config/pgcli/config

To have the database engine running all the time:

brew services start postgresql

Windows instructions

To download the Postgres download the installer and follow the prompts.

To get pgcli, you need to install python, then install pip, then follow these instructions

Linux or Linux Subsystem for Windows instructions

  • If using another flavor of Linux the apt and service instructions may be different. For instance with OpenSUSE the instruction is sudo systemctrl postgresql start instead.
sudo apt install postgresql libpq-dev python-pip
sudo pip install pgcli
# If the command above fails, try:  sudo pip2 install pgcli
sudo service postgresql start
sudo su postgres -c "createuser --superuser ${USER}"

If you have used and configured pgcli you may skip the next instruction:

pgcli >/dev/null 2>&1
sed -i "s/multiline_continuation_char = ''/multiline_continuation_char = '.'/g" ~/.config/pgcli/config
sed -i "s/multi_line = False/multi_line = True/g" ~/.config/pgcli/config
sed -i "s/enable_pager = True/enable_pager = False/g" ~/.config/pgcli/config
sed -i "s/wider_completion_menu = False/wider_completion_menu = True/g" ~/.config/pgcli/config
sed -i "s/syntax_style = default/syntax_style=native/g" ~/.config/pgcli/config

Linux Subsystem Starting PostgreSQL after a reboot

For every session when you want to do database work, execute this command:

sudo service postgresql start