thanosql


Namethanosql JSON
Version 1.0.11 PyPI version JSON
download
home_pagehttps://github.com/smartmind-team/thanosql-python
SummaryThanoSQL SDK for Python
upload_time2024-11-11 05:59:15
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/d8/1b/65c82a07ea5944bb2622e2243d44a4974faa5e47f3ae78d01ac094ea58cb/thanosql-1.0.11.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": "1.0.11",
    "project_urls": {
        "Homepage": "https://github.com/smartmind-team/thanosql-python"
    },
    "split_keywords": [
        "smartmind",
        "thanosql",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f99139899670fa402a8abd5eff265a99937430cf9896cf4992bb1e635943e439",
                "md5": "02852d76cad01a10268bb40f361d6b86",
                "sha256": "12bbac9775ed19d11fddb48170266708c2a0b23e06b4cf7965a0214e36624efd"
            },
            "downloads": -1,
            "filename": "thanosql-1.0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "02852d76cad01a10268bb40f361d6b86",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 28901,
            "upload_time": "2024-11-11T05:59:14",
            "upload_time_iso_8601": "2024-11-11T05:59:14.027197Z",
            "url": "https://files.pythonhosted.org/packages/f9/91/39899670fa402a8abd5eff265a99937430cf9896cf4992bb1e635943e439/thanosql-1.0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d81b65c82a07ea5944bb2622e2243d44a4974faa5e47f3ae78d01ac094ea58cb",
                "md5": "8594b6b184649aa4f28e1f461993bf54",
                "sha256": "eb2e508bb6e79f4ef4e84a49ca4e4332665d0a36711162823e8165a90619ddc8"
            },
            "downloads": -1,
            "filename": "thanosql-1.0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "8594b6b184649aa4f28e1f461993bf54",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 30250,
            "upload_time": "2024-11-11T05:59:15",
            "upload_time_iso_8601": "2024-11-11T05:59:15.930333Z",
            "url": "https://files.pythonhosted.org/packages/d8/1b/65c82a07ea5944bb2622e2243d44a4974faa5e47f3ae78d01ac094ea58cb/thanosql-1.0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-11 05:59:15",
    "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.66137s