Skip to main content

No project description provided

Project description

Local Redash

local-redash is a command line client for redash.

Description

local-redash is a command line tool that can list queries, list data sources, execute queries and display results.

Supported Python Versions

3.10.x and greater

Installation

Use the package manager pip to install local-redash.

pip install local-redash

Configuration

The configuration file is automatically created in ~/.config/local_redash/config.yml at first startup. See the file itself for a description of all available options. The data is displayed using python-tabulate, which can be configured in the table_format of the config.yml.

Usage

Set environment variables

  • Set the redash api url and api key to environment variables
    • REDASH_URL: Sets the API endpoint, which will be the base URL for Redash.
    • API_KEY: Set the redash API key.You can find it on the User Profiles page.
  • Check the redash documentation for details.
$ export REDASH_URL=YOUR_REDASH_API_URL
$ export API_KEY=YOUR_REDASH_API_KEY

CLI Usage

  • Show help
$ local-redash --help

Usage: local-redash [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  data-source-list
  export-query
  query
  query-list
  show-query
  • Show data source list
$ local-redash data-source-list

+------+--------+----------------+----------+----------+-------------+--------+
|   id | name   | pause_reason   | syntax   |   paused | view_only   | type   |
+======+========+================+==========+==========+=============+========+
|    1 | test   | None           | sql      |        0 | False       | pg     |
+------+--------+----------------+----------+----------+-------------+--------+
  • Show query list
    • Columns to be displayed are set in config.yml.
$ local-redash query-list

+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+
|   id | name                    |   data_source_id | runtime               | retrieved_at             | created_at               |
+======+=========================+==================+=======================+==========================+==========================+
|    1 | test-01                 |                1 | 0.0031499862670898438 | 2023-01-01T00:00:00.000Z | 2023-01-01T00:00:00.000Z |
+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+
|    2 | test-02                 |                1 | 0.0031499862670898438 | 2023-01-01T00:00:00.000Z | 2023-01-01T00:00:00.000Z |
+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+
|    3 | test-03                 |                1 | 18.041463136672974    | 2023-01-01T00:00:00.000Z | 2023-01-01T00:00:00.000Z |
+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+
  • Show query
$ local-redash show-query --query-id [query id]

+----------------------------------------------------------------------------------------------------------------------+
| query                                                                                                                |
+======================================================================================================================+
| select     film.film_id,     film.title,     film,     description,     rating from film inner join film_category on |
| film.film_id = film_category.film_id inner join category on film_category.category_id = category.category_id where   |
| category.name = 'Comedy'                                                                                             |
+----------------------------------------------------------------------------------------------------------------------+
  • Run query
$ local-redash query --query-file [query file path] --data-source-id [data source]

ex. $ local-redash query --query-file ./select_test.sql --data-source-id 1

+---------------+----------+----------------------+
|   language_id | name     | last_update          |
+===============+==========+======================+
|             1 | English  | 2022-02-15T10:02:19Z |
+---------------+----------+----------------------+
|             2 | Italian  | 2022-02-15T10:02:19Z |
+---------------+----------+----------------------+
|             3 | Japanese | 2022-02-15T10:02:19Z |
+---------------+----------+----------------------+
|             4 | Mandarin | 2022-02-15T10:02:19Z |
+---------------+----------+----------------------+
|             5 | French   | 2022-02-15T10:02:19Z |
+---------------+----------+----------------------+
|             6 | German   | 2022-02-15T10:02:19Z |
+---------------+----------+----------------------+
  • Export query
$ local-redash export-query --query-name [query name] ----file-path [file path]

ex. $ local-redash export-query --query-name "query_test" --file-path ./

+------------------------+
| exported-query         |
+========================+
| select * from language |
+------------------------+

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

local_redash-0.0.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

local_redash-0.0.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file local_redash-0.0.2.tar.gz.

File metadata

  • Download URL: local_redash-0.0.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for local_redash-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5fe0b0f35cc90c8cf0840c214c53d83a951b00bd4e9023b7767aa11bbfa67500
MD5 73413768a331c98e9dcee32366341db0
BLAKE2b-256 d5bbb53a8b5802a4961aad19935afea787d4ea2bc7f81847286a88fe74e09064

See more details on using hashes here.

File details

Details for the file local_redash-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: local_redash-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for local_redash-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f0dd968aee1b6af45121f73f581e357436c73f0dc7692cd91e5122a3f0be8c4f
MD5 f36faaa1ffa205e3c55d133490337b6e
BLAKE2b-256 a0c0e345342add472de6908fe30b8e0e7291ed2237a94dd645a0ddff71f93c2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page