funnymay
funnymay

Reputation: 391

How can I programmatically download data from QuestDB?

Is there a way to download query results from the database such as tables or other datasets? The UI supports a CSV file download, but this is manual work to browse and download files at the moment. Is there a way I can automate this? Thanks

Upvotes: 3

Views: 764

Answers (1)

Brian Smith
Brian Smith

Reputation: 1315

You can use the export REST API endpoint, this is what the UI uses under the hood. To export a table via this endpoint:

curl -G --data-urlencode "query=select * from my_table" http://localhost:9000/exp

query= may be any SQL query, so if you have a report with more granularity that needs to be regularly generated, this may be passed into the request. If you don't need anything complicated, you can redirect curl output to file

curl -G --data-urlencode "query=select * from my_table" \
http://localhost:9000/exp > myfile.csv

Upvotes: 3

Related Questions