Schedule report to automatically output to a file

Is there a way to schedule a report and have it automatically output to a file? The use case it to automatically import the data into a data warehouse from the output file.

To break it down to separate questions:

  1. How to schedule a report (pulse?)
  2. How to automatically write or append a report to an existing file for import by another program.

Hi @markd
You can perhaps use a service, which converts email attachments (CSV) to your warehouse.
Or use the API to manually get question data based on your own schedule.
Either way, you have to be a little creative yourself - there's no two-clicks-and-you're-done function.

Hi @flamber,

Thanks for the timely response.

I think the API is the better idea.

I'm assuming that there is a way to call an API to run the report/question and receive data back from that - is that correct? That task could be run on a schedule, which will receive the data and write it to a log file.

If so, could you point me to an example of it? e.g. using curl or python? I'll also check myself, but it would be nice to have your confirmation.

Best regards,

The get_card_data function from this Python wrapper for Metabase API can help you achieve that.

Thanks for that script. More questions, of course!

def get_card_data(self, card_name=None, card_id=None, collection_name=None, 
                  collection_id=None, data_format='json', parameters=None):
  1. Is card_name the same as a question as listed on the interface?
  2. I'm assuming collection is the one the card is stored in, is that correct?
  3. Are the parameters a list of parameters that would be provided to the query? e.g. startDate, endDate etc?

Best regards,

1- Card and Question are the same thing. For more accurate results work with card_id as it's unique (although if you work with card_name and there are more than one card with that name, a ValueError is raised).
2- Correct
3- Correct. This was added recently and tested with Native queries (filter_variable_name is the name you use inside [[ {{}} ]], this example may help). Some changes may be needed for Simple/Custom Queries.