This section describes how to use export-csv.sh to export data from IoTDB to a CSV file.
Exporting data to CSV files may cause injection risks. Exercise caution when performing this operation.
cd /opt/client/IoTDB/iotdb/tools
select * from root.fit.d1 select * from root.sg1.d1
./export-csv.sh -h Service IP address of the IoTDBServer instance -p IoTDBServer RPC port -td <directory> [-tf <time-format> -s <sqlfile>]
Example:
./export-csv.sh -h x.x.x.x -p 22260 -td ./ # Or ./export-csv.sh -h x.x.x.x -p 22260 -td ./ -tf yyyy-MM-dd\ HH:mm:ss # Or ./export-csv.sh -h x.x.x.x -p 22260 -td ./ -s sql.txt # Or ./export-csv.sh -h x.x.x.x -p 22260 -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt
For example, after you enter yes, enter the service username and password as prompted. If information in the following figure is displayed, the data is exported:
./export-csv.sh -h x.x.x.x -p 22260 -u test -pw Password -td ./ # Or ./export-csv.sh -h x.x.x.x -p 22260 -u test -pw Password -td ./ # Or ./export-csv.sh -h x.x.x.x -p 22260 -u test -pw Password -td ./ -s sql.txt # Or ./export-csv.sh -h x.x.x.x -p 22260 -u test -pw Password -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt
If information in the following figure is displayed, the CSV file is exported: