4

I have a few tables in the database in a Hasura cluster. I want to export one them as a CSV file (with the data). How can I do this?

2 Answers 2

4

You can follow one of the following methods:

  1. Connect to the database and use psql to export data as CSV:

    a) Directly access the underlying Postgres db instance:

    hasura microservice port-forward postgres -n hasura --local-port 6432

    b) follow this SO question to actually export data as a CSV file (assumes you have psql installed).

  2. Use the data APIs to write a simple service that can convert JSON to CSV and save it to a file.

  3. If the size of the table isn't huge, you can also just use the api-explorer UI (either the Data section or the SQL interface) to display all the rows and copy & paste them into a file. It's pretty straightforward to convert this file into CSV format.
Sign up to request clarification or add additional context in comments.

Comments

4

Hasura exposes an API endpoint for accessing pg_dump of the underlying database:

curl --location --request POST 'https://<hasura-hostname>/v1alpha1/pg_dump' --header 'x-hasura-admin-secret: <password>' --header 'Content-Type: application/json' --data-raw '{  "opts": ["-O", "-x", "--schema", "public", "--schema", "auth"],  "clean_output": true}' -o backup.sql

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.