Skip to content

Instantly share code, notes, and snippets.

@rg3915
Created December 22, 2018 16:53
Show Gist options
  • Select an option

  • Save rg3915/00f54014482327d0780ce81d148d5977 to your computer and use it in GitHub Desktop.

Select an option

Save rg3915/00f54014482327d0780ce81d148d5977 to your computer and use it in GitHub Desktop.
Importando CSV do PostgreSql do Heroku

Importando CSV do PostgreSql do Heroku

Conectando no banco no Heroku

heroku pg:psql --app pgsa-adv

Dica: se você quiser ver as credenciais para conectar-se via pgadmin 3 (requer SSL MODE - não consegui conectar), por exemplo, digite:

heroku pg:credentials:url DATABASE

Mostrando tabelas

\dt

Exportando os dados para um CSV

\copy (SELECT * FROM auth_user) TO auth_user.csv CSV DELIMITER ';' HEADER

Exportando direto do banco do Heroku sem abrir o bd

heroku pg:psql -c "\COPY (SELECT * FROM auth_user) TO auth_user.csv CSV DELIMITER ';' HEADER"

Fonte: http://icephoenix.us/stuff/how-export-results-of-postgres-to-csv-on-heroku/

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