2
votes

So basically i want to export a database from influxdb to csv format in command line.

I type this command in the command line:

influx -database 'RoadMonitoringDB' -execute 'select * from vehicle' -format 'csv' > test.csv

It supposed to correctly export it into csv file, but what i get now is this:

unknown arguments: * from vehicle' -format 'csv'

What went wrong here? Because when i type influx -help, the command should be like this:

influx -database 'metrics' -execute 'select * from cpu' -format 'json' -pretty

Any answers is really helpful. Thank you in advance :)

3

3 Answers

0
votes

which version are you using? I just checked it on 1.7.6 and it works fine:

[root@mon-01 ~]# influx -version
InfluxDB shell version: 1.7.6
Enter an InfluxQL query
[root@mon-01 ~]# influx -precision 'rfc3339' -database 'myMetrics' -execute 'select * from up' -format 'csv' >up.txt

BTW - the -precision 'rfc3339' is just for getting a readable timestamp.

0
votes

I compared to how I do it, and the only difference I found was:

You are writing:

-format 'csv' > test.csv

I write it as:

-format csv > test.csv
0
votes

Remove single quote from CSV, it works

$ influx -database 'RoadMonitoringDB' -execute 'select * from vehicle' -format 'csv' > test.csv

But in the result, the timestamp will look like this:

1204554500000000000

So to get the timestamp in RFC3339 formats, like this:

2021-06-06T00:00:00
$ influx -precision 'rfc3339' -database 'RoadMonitoringDB' -execute 'select * from vehicle' -format 'csv' > test.csv