Skip to content

Instantly share code, notes, and snippets.

@kalpesh-fulpagare
Created February 8, 2016 12:39
Show Gist options
  • Save kalpesh-fulpagare/f4fe71bfcdc69ef557a6 to your computer and use it in GitHub Desktop.
Save kalpesh-fulpagare/f4fe71bfcdc69ef557a6 to your computer and use it in GitHub Desktop.
Heroku DB Table - Export CSV
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 30 in line 1.
heroku pg:psql --app APP_NAME
\copy (SELECT users.id, CONCAT(first_name, ' ', middle_name, ' ', last_name) AS full_name, username, dob, gender, address_line_1, address_line_2, province, zipcode, email, phone_number, minor, roles.name as role, avatar_url, email_frequency, sign_in_count, license_code, city, elise_points, used_points, contact_person, phone, website, chamber_of_commerce_no, notes FROM users LEFT JOIN roles on role_id=roles.id) TO users-8feb-2016.csv CSV HEADER DELIMITER ','
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment