Skip to content

Instantly share code, notes, and snippets.

@tvandervossen
Created September 24, 2013 16:54
Show Gist options
  • Save tvandervossen/6687723 to your computer and use it in GitHub Desktop.
Save tvandervossen/6687723 to your computer and use it in GitHub Desktop.
PostgreSQL for people who just need to get some data out of a dump from Heroku
Start the console (or whatever it’s called):
$ /Applications/Postgres.app/Contents/MacOS/bin/psql
Create a database:
thijs=# create database adj2013;
Import the dump:
$ /Applications/Postgres.app/Contents/MacOS/bin/pg_restore --verbose --clean --no-acl --no-owner -h localhost -d adj2013 data/2013/database.dump
Select the database:
thijs=# \c adj2013
You are now connected to database "adj2013" as user "thijs".
Show the table structure:
adj2013=# \d+ votes
Run a query and export the result as CSV:
adj2013=# \copy (select salutation, first_name, last_name, email, birth_date, normalized_email, confirmed, disqualified from votes) To '/Users/thijs/Desktop/adj2013.csv' With CSV;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment