local-redash


Namelocal-redash JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/myoshioka/local-redash
SummaryNone
upload_time2024-04-11 09:12:35
maintainerNone
docs_urlNone
authorMakoto Yoshioka
requires_python<4.0,>=3.10
licenseMIT
keywords redash sql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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](https://pip.pypa.io/en/stable/) to install local-redash.

```bash
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](https://github.com/astanin/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](https://redash.io/help/user-guide/integrations-and-api/api) documentation for details.

```bash
$ export REDASH_URL=YOUR_REDASH_API_URL
$ export API_KEY=YOUR_REDASH_API_KEY
```

### CLI Usage

- Show help
```bash
$ 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

```bash
$ 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.

```bash
$ 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

```bash
$ 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

```bash
$ 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

```bash
$ 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](https://choosealicense.com/licenses/mit/)




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/myoshioka/local-redash",
    "name": "local-redash",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "redash, sql",
    "author": "Makoto Yoshioka",
    "author_email": "y.mako2@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d5/bb/b53a8b5802a4961aad19935afea787d4ea2bc7f81847286a88fe74e09064/local_redash-0.0.2.tar.gz",
    "platform": null,
    "description": "# Local Redash\n\nlocal-redash is a command line client for redash.\n\n## Description\n\nlocal-redash is a command line tool that can list queries, list data sources, execute queries and display results.\n\n## Supported Python Versions\n\n3.10.x and greater\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install local-redash.\n\n```bash\npip install local-redash\n```\n\n## Configuration\n\nThe 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.\nThe data is displayed using [python-tabulate](https://github.com/astanin/python-tabulate), which can be configured in the `table_format` of the config.yml.\n\n## Usage\n\n### Set environment variables\n\n- Set the redash api url and api key to environment variables\n  - **REDASH_URL**: Sets the API endpoint, which will be the base URL for Redash.\n  - **API_KEY**: Set the redash API key.You can find it on the User Profiles page.\n- Check the [redash](https://redash.io/help/user-guide/integrations-and-api/api) documentation for details.\n\n```bash\n$ export REDASH_URL=YOUR_REDASH_API_URL\n$ export API_KEY=YOUR_REDASH_API_KEY\n```\n\n### CLI Usage\n\n- Show help\n```bash\n$ local-redash --help\n\nUsage: local-redash [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n  --help  Show this message and exit.\n\nCommands:\n  data-source-list\n  export-query\n  query\n  query-list\n  show-query\n```\n\n- Show data source list\n\n```bash\n$ local-redash data-source-list\n\n+------+--------+----------------+----------+----------+-------------+--------+\n|   id | name   | pause_reason   | syntax   |   paused | view_only   | type   |\n+======+========+================+==========+==========+=============+========+\n|    1 | test   | None           | sql      |        0 | False       | pg     |\n+------+--------+----------------+----------+----------+-------------+--------+\n```\n\n- Show query list\n  - Columns to be displayed are set in config.yml.\n\n```bash\n$ local-redash query-list\n\n+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+\n|   id | name                    |   data_source_id | runtime               | retrieved_at             | created_at               |\n+======+=========================+==================+=======================+==========================+==========================+\n|    1 | test-01                 |                1 | 0.0031499862670898438 | 2023-01-01T00:00:00.000Z | 2023-01-01T00:00:00.000Z |\n+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+\n|    2 | test-02                 |                1 | 0.0031499862670898438 | 2023-01-01T00:00:00.000Z | 2023-01-01T00:00:00.000Z |\n+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+\n|    3 | test-03                 |                1 | 18.041463136672974    | 2023-01-01T00:00:00.000Z | 2023-01-01T00:00:00.000Z |\n+------+-------------------------+------------------+-----------------------+--------------------------+--------------------------+\n```\n\n- Show query\n\n```bash\n$ local-redash show-query --query-id [query id]\n\n+----------------------------------------------------------------------------------------------------------------------+\n| query                                                                                                                |\n+======================================================================================================================+\n| select     film.film_id,     film.title,     film,     description,     rating from film inner join film_category on |\n| film.film_id = film_category.film_id inner join category on film_category.category_id = category.category_id where   |\n| category.name = 'Comedy'                                                                                             |\n+----------------------------------------------------------------------------------------------------------------------+\n```\n\n- Run query\n\n```bash\n$ local-redash query --query-file [query file path] --data-source-id [data source]\n\nex. $ local-redash query --query-file ./select_test.sql --data-source-id 1\n\n+---------------+----------+----------------------+\n|   language_id | name     | last_update          |\n+===============+==========+======================+\n|             1 | English  | 2022-02-15T10:02:19Z |\n+---------------+----------+----------------------+\n|             2 | Italian  | 2022-02-15T10:02:19Z |\n+---------------+----------+----------------------+\n|             3 | Japanese | 2022-02-15T10:02:19Z |\n+---------------+----------+----------------------+\n|             4 | Mandarin | 2022-02-15T10:02:19Z |\n+---------------+----------+----------------------+\n|             5 | French   | 2022-02-15T10:02:19Z |\n+---------------+----------+----------------------+\n|             6 | German   | 2022-02-15T10:02:19Z |\n+---------------+----------+----------------------+\n```\n\n- Export query\n\n```bash\n$ local-redash export-query --query-name [query name] ----file-path [file path]\n\nex. $ local-redash export-query --query-name \"query_test\" --file-path ./\n\n+------------------------+\n| exported-query         |\n+========================+\n| select * from language |\n+------------------------+\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": null,
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/myoshioka/local-redash",
        "Repository": "https://github.com/myoshioka/local-redash"
    },
    "split_keywords": [
        "redash",
        " sql"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0c0e345342add472de6908fe30b8e0e7291ed2237a94dd645a0ddff71f93c2a",
                "md5": "f36faaa1ffa205e3c55d133490337b6e",
                "sha256": "f0dd968aee1b6af45121f73f581e357436c73f0dc7692cd91e5122a3f0be8c4f"
            },
            "downloads": -1,
            "filename": "local_redash-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f36faaa1ffa205e3c55d133490337b6e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 14401,
            "upload_time": "2024-04-11T09:12:34",
            "upload_time_iso_8601": "2024-04-11T09:12:34.420708Z",
            "url": "https://files.pythonhosted.org/packages/a0/c0/e345342add472de6908fe30b8e0e7291ed2237a94dd645a0ddff71f93c2a/local_redash-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5bbb53a8b5802a4961aad19935afea787d4ea2bc7f81847286a88fe74e09064",
                "md5": "73413768a331c98e9dcee32366341db0",
                "sha256": "5fe0b0f35cc90c8cf0840c214c53d83a951b00bd4e9023b7767aa11bbfa67500"
            },
            "downloads": -1,
            "filename": "local_redash-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "73413768a331c98e9dcee32366341db0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 11238,
            "upload_time": "2024-04-11T09:12:35",
            "upload_time_iso_8601": "2024-04-11T09:12:35.883463Z",
            "url": "https://files.pythonhosted.org/packages/d5/bb/b53a8b5802a4961aad19935afea787d4ea2bc7f81847286a88fe74e09064/local_redash-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-11 09:12:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "myoshioka",
    "github_project": "local-redash",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "local-redash"
}
        
Elapsed time: 0.20394s