Skip to content

Instantly share code, notes, and snippets.

@wbobeirne
Last active June 7, 2018 16:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbobeirne/c2aea15cd15c15254747d36a04044794 to your computer and use it in GitHub Desktop.
Save wbobeirne/c2aea15cd15c15254747d36a04044794 to your computer and use it in GitHub Desktop.

When starting a new project with a Postgres database, you'll want to do the following things to set it up:

1) Create the Database

Depending on which operating system you're on, you'll need to do the following:

OSX

  1. Open your terminal
  2. Run psql --username=postgres, enter the password you made for postgres
  3. Once you're in the psql prompt, run CREATE DATABASE <name_of_database>; MAKE SURE YOU SEMICOLON!

Windows

  1. Open the SQL Prompt (Search psql in the application finder)
  2. Hit enter through all of the default options
  3. Enter your postgres password when prompted
  4. Once you're in the psql prompt, run CREATE DATABASE <name_of_database>; MAKE SURE YOU SEMICOLON!

Linux

  1. Open your terminal
  2. Run psql --username=postgres -W, enter the password you made for postgres
  3. Once you're in the psql prompt, run CREATE DATABASE <name_of_database>; MAKE SURE YOU SEMICOLON!

* If you followed this guide, you should be able to leave out --username=postgres -W
*If you get an error about no database running, run sudo service postgresql start

2) Setup Your SQL GUI

Depending on which GUI you have installed, you'll need to do different things

PSequel

  • Open up the PSequel application
  • Hit "Add Connection" in the bottom left
  • Fill out the form with the following data:

inline

  • Try to connect!

Sqlectron

  • Open up the Sqlectron application
  • Hit "Add" in the upper right
  • Fill out the form with the following data:

inline

  • Run "Test" before saving
  • If all goes well, go ahead and save

*If test is still greyed out, that means you missed a field. Make sure you set database type in the top right!

3) Create the Tables You Need

Your project probably requires some tables to be set up. Where you do that depends on which GUI you're using:

PSequel

  1. Connect to the database you set up previously
  2. In the top center of the application, click the "Query" tab
  3. Enter your CREATE TABLE ... query and hit "Run Query"
  4. Hit the refresh button in the bottom left of the application, you should see your new table

inline

Sqlectron

  1. Connect to the database you set up previously
  2. In the center of the screen, you should have a SQL prompt
  3. Enter your CREATE TABLE ... query and hit "Execute"
  4. Expand your database on the left side, and search for the name of your table, you should see public.<name_of_table>

inline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment