All Products
Search
Document Center

:How to export command execution results to a CSV file

Last Updated:Dec 29, 2020

Overview

This topic describes how to export the execution results of a command to a CSV file.

Detail

  1. 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.
  2. 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:
    • [$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.csv command to view the content of the. Csv file and verify data integrity.
    The following command output is returned.

Application scope

  • ApsaraDB for Redis