You want to export a database table (or a part of it) to a CSV file.
You will need:
- Platform CLI
The platform CLI tool allows you to connect to your database using the command
You can also specify which query you want to run. This will show you all the tables in your database.
platform sql "SHOW TABLES"
With this, piping it to a file then becomes trivial. Just add
--raw to your command to make the output machine readable. If there is more than one column, it will be separated by a TAB character.
platform sql "SHOW TABLES" --raw > all_tables.csv
To export data from the table
items, in the database
main simply do:
platform sql "SELECT id, title FROM items LIMIT 10" --raw --schema=main > tab_separated_output.csv
The resulting file can be opened with any spreadsheet software (libreoffice, openoffice, MS Office). Simply select TAB as a column separator.
Note that these queries will run on your database server. If the tables are large, exporting them can take a while.
For more information on what is possible with platform sql try
platform sql --help
or checkout the platform cli git repository https://github.com/platformsh/platformsh-cli