Hi,

I have some python scripts that I would like to execute from redash UI (not in redash), then read the resulting json files into redash. This is in Ubuntu 16.04.

Is that possible? Any examples?

br, perza

I’m not sure what this means. But you can enable and use the Python query runner to execute Python and visualize an output. To enable it add this to your environment:

  REDASH_ADDITIONAL_QUERY_RUNNERS: "redash.query_runner.python"

We don’t have documentation for the Python query runner (yet – would love to merge a PR adding these). But you can inspect the query_runner code directly to see what is required.

Your query should contain a result variable that contains a dictionary conforming with Redash’s desired data format. A super simple query example:

result = {
  "columns": [
    {
      "name": "date",
      "type": "date",
      "friendly_name": "date"
    },
    {
      "name": "day_number",
      "type": "integer",
      "friendly_name": "day_number"
    },
    {
      "name": "value",
      "type": "integer",
      "friendly_name": "value"
    },
    {
      "name": "total",
      "type": "integer",
      "friendly_name": "total"
    }
  ],
  "rows": [
    {
      "value": 40832,
      "total": 53141,
      "day_number": 0,
      "date": "2014-01-30"
    },
    {
      "value": 27296,
      "total": 53141,
      "day_number": 1,
      "date": "2014-01-30"
    },
    {
      "value": 22982,
      "total": 53141,
      "day_number": 2,
      "date": "2014-01-30"
    }
  ]
}

Yields this result:

1 Like