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.
Can you please try with this minor correction?
influx -database ‘chirpstack’ -execute "SELECT * FROM device_frmpayload_data_BC" -format csv > test.csv
Looks like you run the query inside the influx prompt instead of the OS command line.
i am using the following command on iinflux2 CLI t get raw data in .csv from inflluxdb2:
influx query ‘from(bucket:“example-bucket”) |> range(start:-1m)’ --raw
But I get the error: Error: failed to execute query: 400 Bad Request: error @1:13-1:16: undefined identifier example-bucket
Could you please let me know where i am making a mistake?
It looks like you don’t have a bucket called “example-bucket”
Can you please share the results of:
influx bucket list please? You might also want to try using the bucketID just in case you included spaces or special characters when creating the bucket name.
If I save the same query in a file and then run the cli command by calling the file with the path, it works.