Overview
This topic describes how to export the execution results of a command to a CSV file.
Detail
- To export data from apsaradb for Redis to an external program, you can use redis-cli to export the result to a CSV file.
Note:
- The ECS instance and the apsaradb for Redis instance can interconnect with each other.
- The ECS instance is Linux.
- You have installed the redis-cli program on the ECS instance.
- Log on to the ECS instance and run the command in the following template.
redis-cli -h [$Host] -a [$Password] --csv [$Redis_command] > [$Filename].csv
Note:
The following command output is returned.
- [$Host]: the connection address of the apsaradb for Redis instance.
- [$Password]: specifies the Password. If you have enabled virtual private cloud (VPC) Password-free authentication, you do not need to enter the Password as shown in the preceding figure.
- [$Redis_command]: specifies the Redis command to run. In this example, the HGETALL customer:4955 command is used. You can only run one command.
- [$Filename]: specifies the file name.
- The Redis data in the example is the virtual data used for testing.
- Use
cat. /Clientfilenamename.csvcommand to view the content of the. Csv file and verify data integrity.

Application scope
- ApsaraDB for Redis