Export influx database to a csv file

I’ve my time series data stored in a (InfluxDB) database. The database contains 9 measurements (or tables) in total. I wish to export data to a csv file and store the csv files. I tried the following command:

influx -database ‘chirpstack’ -execute ‘SELECT * FROM device_frmpayload_data_BC’ -format csv > test.csv

But it throws the following error:

ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1

How do I fix the error? Also I’d like to know if there’s a way by which I can export the database in one go, instead of exporting one measurement/table one at a time? Many thanks in advance.

Hello @samdanisms,
Can you please try with this minor correction?

influx -database ‘chirpstack’ -execute "SELECT * FROM device_frmpayload_data_BC" -format csv > test.csv

Thank you

Looks like you run the query inside the influx prompt instead of the OS command line.