Created
September 24, 2013 16:54
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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