thanosql


Namethanosql JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/smartmind-team/thanosql-python
SummaryThanoSQL SDK for Python
upload_time2024-04-26 06:41:25
maintainerNone
docs_urlNone
authorSmartMind
requires_python>=3.8
licenseMIT
keywords smartmind thanosql sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ThanoSQL Python Library

The ThanoSQL Python library provides convenient access to the ThanoSQL API from any Python 3.8+ application. The library covers all ThanoSQL operations that users can do, such as querying, editing tables, and much more.

## Installation

Refer to the following instructions to install the ThanoSQL Python library from PyPI.

```bash
pip install thanosql
```

> [!WARNING]
> Make sure to uninstall ThanoSQL Magic first.
>
> `pip uninstall thanosql-magic`
>
> In order to use the library with ThanoSQL Magic,
>
> `pip install 'thanosql[magic]'`

Alternatively, you can also install from source. First, clone this repository.

```bash
git clone https://github.com/smartmind-team/thanosql-sdk-python.git
cd thanosql-sdk-python
```

Install the SDK by using `pip install`. Note that the Python version used during development is 3.8.10.

```bash
pip install -e .
pip install -e ."[dev]" # include unit test & docs (requires python >= 3.9)
pip install -e ."[magic]" # include magic
```

## Usage

In order to use the library, a working workspace engine is required. Create a new Python or IPython notebook file. Import the `thanosql` package, create a `ThanoSQL` client with your API token and engine URL, and then you can use all the functions in the library. For more examples, head over to the [examples](./docs/examples/) directory.

1. First, set up your API_TOKEN and ENGINE_URL (recommended). You can find them by accessing your workspace's settings page. Head over to the `Developer` tab, and then copy your API Token and Engine URL.

   ```bash
   export THANOSQL_API_TOKEN='your-api-token-here'
   export THANOSQL_ENGINE_URL='your-engine-url-here'
   ```

2. Import the ThanoSQL client and use it to query your ThanoSQL Workspace.

   ```python
   from thanosql import ThanoSQL

   client = ThanoSQL()
   # defaults to getting the token using os.environ.get("THANOSQL_API_TOKEN"),
   # and also defaults to getting the url using os.environ.get("THANOSQL_ENGINE_URL"),
   # client = ThanoSQL(
   #     api_token='your-api-token-here',
   #     engine_url='your-engine-url-here'
   # )

   res = client.query.execute(query="SELECT 1")
   print(res.model_dump_json(indent=4))

   tables = client.table.list(schema="public")

   # do something with the list of tables
   for table in tables:
      print(table.name)
   ```

## Magic

`thanosql-magic` is a Jupyter Notebook extension that provides SQL query capabilities using [ThanoSQL](https://www.thanosql.ai). This magic extension enables users to interact with ThanoSQL Workspace databases using extended SQL syntax within a Jupyter notebook.

`thanosql-magic` uses IPython magic. [IPython magic](https://ipython.readthedocs.io/en/stable/interactive/magics.html) is a special command that can be used in the IPython shell to perform specific tasks before executing the code. Since Jupyter includes the IPython shell, you can also use these magic commands in Jupyter Notebook.

IPython magic commands are prefixed with % or %% and % applies the magic to a single line of code, while %% applies the magic to multiple lines of code.

### Installation

To install thanosql-magic, you can use pip:

```bash
pip install 'thanosql[magic]'
```

Once installed, you can load the extension in your Jupyter notebook by running:

```python
%load_ext thanosql
```

### Usage

After loading the extension, you can connect to your ThanoSQL Engine instance by setting the thanosql variable:

1. Setting API_TOKEN

   ```python
   %thanosql API_TOKEN=<Issued_API_TOKEN>
   ```

2. Changing the Default API URI (Optional)

   ```python
   %thanosql http://localhost:8000/api/v1/query
   ```

3. Using Magic Commands

   You can then execute SQL queries on your Thanos data using the %thanosql magic command:

   ```python
   %%thanosql
   SELECT * FROM users
   ```

   This will run the SQL query and display the results in your Jupyter notebook.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/smartmind-team/thanosql-python",
    "name": "thanosql",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "smartmind thanosql sdk",
    "author": "SmartMind",
    "author_email": "dev@smartmind.team",
    "download_url": "https://files.pythonhosted.org/packages/7c/c7/d0764a6ecb0e043467b881ef9036f9576006855c7653b7ee290f75134d3b/thanosql-0.2.3.tar.gz",
    "platform": null,
    "description": "# ThanoSQL Python Library\n\nThe ThanoSQL Python library provides convenient access to the ThanoSQL API from any Python 3.8+ application. The library covers all ThanoSQL operations that users can do, such as querying, editing tables, and much more.\n\n## Installation\n\nRefer to the following instructions to install the ThanoSQL Python library from PyPI.\n\n```bash\npip install thanosql\n```\n\n> [!WARNING]\n> Make sure to uninstall ThanoSQL Magic first.\n>\n> `pip uninstall thanosql-magic`\n>\n> In order to use the library with ThanoSQL Magic,\n>\n> `pip install 'thanosql[magic]'`\n\nAlternatively, you can also install from source. First, clone this repository.\n\n```bash\ngit clone https://github.com/smartmind-team/thanosql-sdk-python.git\ncd thanosql-sdk-python\n```\n\nInstall the SDK by using `pip install`. Note that the Python version used during development is 3.8.10.\n\n```bash\npip install -e .\npip install -e .\"[dev]\" # include unit test & docs (requires python >= 3.9)\npip install -e .\"[magic]\" # include magic\n```\n\n## Usage\n\nIn order to use the library, a working workspace engine is required. Create a new Python or IPython notebook file. Import the `thanosql` package, create a `ThanoSQL` client with your API token and engine URL, and then you can use all the functions in the library. For more examples, head over to the [examples](./docs/examples/) directory.\n\n1. First, set up your API_TOKEN and ENGINE_URL (recommended). You can find them by accessing your workspace's settings page. Head over to the `Developer` tab, and then copy your API Token and Engine URL.\n\n   ```bash\n   export THANOSQL_API_TOKEN='your-api-token-here'\n   export THANOSQL_ENGINE_URL='your-engine-url-here'\n   ```\n\n2. Import the ThanoSQL client and use it to query your ThanoSQL Workspace.\n\n   ```python\n   from thanosql import ThanoSQL\n\n   client = ThanoSQL()\n   # defaults to getting the token using os.environ.get(\"THANOSQL_API_TOKEN\"),\n   # and also defaults to getting the url using os.environ.get(\"THANOSQL_ENGINE_URL\"),\n   # client = ThanoSQL(\n   #     api_token='your-api-token-here',\n   #     engine_url='your-engine-url-here'\n   # )\n\n   res = client.query.execute(query=\"SELECT 1\")\n   print(res.model_dump_json(indent=4))\n\n   tables = client.table.list(schema=\"public\")\n\n   # do something with the list of tables\n   for table in tables:\n      print(table.name)\n   ```\n\n## Magic\n\n`thanosql-magic` is a Jupyter Notebook extension that provides SQL query capabilities using [ThanoSQL](https://www.thanosql.ai). This magic extension enables users to interact with ThanoSQL Workspace databases using extended SQL syntax within a Jupyter notebook.\n\n`thanosql-magic` uses IPython magic. [IPython magic](https://ipython.readthedocs.io/en/stable/interactive/magics.html) is a special command that can be used in the IPython shell to perform specific tasks before executing the code. Since Jupyter includes the IPython shell, you can also use these magic commands in Jupyter Notebook.\n\nIPython magic commands are prefixed with % or %% and % applies the magic to a single line of code, while %% applies the magic to multiple lines of code.\n\n### Installation\n\nTo install thanosql-magic, you can use pip:\n\n```bash\npip install 'thanosql[magic]'\n```\n\nOnce installed, you can load the extension in your Jupyter notebook by running:\n\n```python\n%load_ext thanosql\n```\n\n### Usage\n\nAfter loading the extension, you can connect to your ThanoSQL Engine instance by setting the thanosql variable:\n\n1. Setting API_TOKEN\n\n   ```python\n   %thanosql API_TOKEN=<Issued_API_TOKEN>\n   ```\n\n2. Changing the Default API URI (Optional)\n\n   ```python\n   %thanosql http://localhost:8000/api/v1/query\n   ```\n\n3. Using Magic Commands\n\n   You can then execute SQL queries on your Thanos data using the %thanosql magic command:\n\n   ```python\n   %%thanosql\n   SELECT * FROM users\n   ```\n\n   This will run the SQL query and display the results in your Jupyter notebook.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "ThanoSQL SDK for Python",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://github.com/smartmind-team/thanosql-python"
    },
    "split_keywords": [
        "smartmind",
        "thanosql",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43c81e43d9bae95ba49d7e1fa5c930b0f29ade035e72a361c6bb4dc15cf60800",
                "md5": "6859a1ede97eb47cbd7c76686debbcf3",
                "sha256": "d6b8c635111d773ec655bd0f156180698ef71964eafab822c99b777315dc1dc1"
            },
            "downloads": -1,
            "filename": "thanosql-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6859a1ede97eb47cbd7c76686debbcf3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 25328,
            "upload_time": "2024-04-26T06:41:24",
            "upload_time_iso_8601": "2024-04-26T06:41:24.270713Z",
            "url": "https://files.pythonhosted.org/packages/43/c8/1e43d9bae95ba49d7e1fa5c930b0f29ade035e72a361c6bb4dc15cf60800/thanosql-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7cc7d0764a6ecb0e043467b881ef9036f9576006855c7653b7ee290f75134d3b",
                "md5": "15dfcb0201e9dec5a05529b23144ee9f",
                "sha256": "292952416cb4416e870f9f81e6236a15f80c40c6952055a25364c74489ba775b"
            },
            "downloads": -1,
            "filename": "thanosql-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "15dfcb0201e9dec5a05529b23144ee9f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 26928,
            "upload_time": "2024-04-26T06:41:25",
            "upload_time_iso_8601": "2024-04-26T06:41:25.389376Z",
            "url": "https://files.pythonhosted.org/packages/7c/c7/d0764a6ecb0e043467b881ef9036f9576006855c7653b7ee290f75134d3b/thanosql-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 06:41:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "smartmind-team",
    "github_project": "thanosql-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "thanosql"
}
        
Elapsed time: 0.26840s