cratedb-async


Namecratedb-async JSON
Version 0.0.8 PyPI version JSON
download
home_pageNone
SummaryAsynchronous http driver for CrateDB
upload_time2025-09-08 08:29:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseCopyright 2025 github.com/surister Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords connector cratedb database driver http
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CrateDB Async driver based on httpx.
![PyPI - Version](https://img.shields.io/pypi/v/cratedb-async)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cratedb-async)
![PyPI - License](https://img.shields.io/pypi/l/cratedb-async)
![PyPI - Status](https://img.shields.io/pypi/status/cratedb-async)
[![Upload](https://github.com/surister/cratedb-async/actions/workflows/python-publish.yml/badge.svg)](https://github.com/surister/cratedb-async/actions/workflows/python-publish.yml)

Asynchronous driver for CrateDB, it uses the HTTP protocol and follows its own design.

## Usage

It can be used with any async library:

#### Asyncio
```python

import asyncio

from cratedb_async.client import CrateClient


async def main():
    crate = CrateClient('http://192.168.88.251:4200')
    response = await crate.query('SELECT * FROM sys.summits')
    print(response.as_table())

asyncio.run(main())

# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+
# | classification | coordinates         | country | first_ascent | height | mountain       | prominence | range         | region               |
# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+
# | I/B-07.V-B     | [6.86444, 45.8325]  | FR/IT   | 1786         | 4808   | Mont Blanc     | 4695       | U-Savoy/Aosta | Mont Blanc massif    |
# | I/B-09.III-A   | [7.86694, 45.93694] | CH      | 1855         | 4634   | Monte Rosa     | 2165       | Valais        | Monte Rosa Alps      |
# | I/B-09.V-A     | [7.85889, 46.09389] | CH      | 1858         | 4545   | Dom            | 1046       | Valais        | Mischabel            |
# | I/B-09.III-A   | [7.83556, 45.92222] | CH/IT   | 1861         | 4527   | Liskamm        | 376        | Valais/Aosta  | Monte Rosa Alps      |
# | I/B-09.II-D    | [7.71583, 46.10139] | CH      | 1861         | 4506   | Weisshorn      | 1235       | Valais        | Weisshorn-Matterhorn |
# | I/B-09.II-A    | [7.65861, 45.97639] | CH/IT   | 1865         | 4478   | Matterhorn     | 1042       | Valais/Aosta  | Weisshorn-Matterhorn |
# | I/B-09.II-C    | [7.61194, 46.03417] | CH      | 1862         | 4357   | Dent Blanche   | 915        | Valais        | Weisshorn-Matterhorn |
# | I/B-09.I-B     | [7.29917, 45.9375]  | CH      | 1859         | 4314   | Grand Combin   | 1517       | Valais        | Grand Combin Alps    |
# | I/B-12.II-A    | [8.12611, 46.53722] | CH      | 1829         | 4274   | Finsteraarhorn | 2280       | Bern/Valais   | Bernese Alps         |
# | I/B-09.II-D    | [7.69028, 46.065]   | CH      | 1864         | 4221   | Zinalrothorn   | 490        | Valais        | Weisshorn-Matterhorn |
# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+
```


#### Trio

```python
import trio

from cratedb_async.client import CrateClient


async def main():
    crate = CrateClient('http://192.168.88.251:4200')
    response = await crate.query('SELECT * FROM sys.summits')
    print(response.as_table())

trio.run(main)

# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+
# | classification | coordinates         | country | first_ascent | height | mountain       | prominence | range         | region               |
# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+
# | I/B-07.V-B     | [6.86444, 45.8325]  | FR/IT   | 1786         | 4808   | Mont Blanc     | 4695       | U-Savoy/Aosta | Mont Blanc massif    |
# | I/B-09.III-A   | [7.86694, 45.93694] | CH      | 1855         | 4634   | Monte Rosa     | 2165       | Valais        | Monte Rosa Alps      |
# | I/B-09.V-A     | [7.85889, 46.09389] | CH      | 1858         | 4545   | Dom            | 1046       | Valais        | Mischabel            |
# | I/B-09.III-A   | [7.83556, 45.92222] | CH/IT   | 1861         | 4527   | Liskamm        | 376        | Valais/Aosta  | Monte Rosa Alps      |
# | I/B-09.II-D    | [7.71583, 46.10139] | CH      | 1861         | 4506   | Weisshorn      | 1235       | Valais        | Weisshorn-Matterhorn |
# | I/B-09.II-A    | [7.65861, 45.97639] | CH/IT   | 1865         | 4478   | Matterhorn     | 1042       | Valais/Aosta  | Weisshorn-Matterhorn |
# | I/B-09.II-C    | [7.61194, 46.03417] | CH      | 1862         | 4357   | Dent Blanche   | 915        | Valais        | Weisshorn-Matterhorn |
# | I/B-09.I-B     | [7.29917, 45.9375]  | CH      | 1859         | 4314   | Grand Combin   | 1517       | Valais        | Grand Combin Alps    |
# | I/B-12.II-A    | [8.12611, 46.53722] | CH      | 1829         | 4274   | Finsteraarhorn | 2280       | Bern/Valais   | Bernese Alps         |
# | I/B-09.II-D    | [7.69028, 46.065]   | CH      | 1864         | 4221   | Zinalrothorn   | 490        | Valais        | Weisshorn-Matterhorn |
# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+

```

#### Bulk insert

```python
import asyncio

from cratedb_async.client import CrateClient


async def main():
    crate = CrateClient('http://192.168.88.251:4200')
    rows = [
        ('one', 2, ['three', ]),
        ('three', 4, ['five', ])
    ]
    table_name = 'my_tbl'
    
    create_table_resp = await crate.query(f'create table {table_name} (one text, two integer, three array(TEXT))')
    print(create_table_resp)
    # SQLResponse(error=None, columns=[], row_count=1, duration=177.55101)

    response = await crate.bulk_insert(table_name, rows)
    print(response)
    # SQLResponse(error=None, columns=[], row_count=0, duration=6.341763)

    await crate.query(f'refresh table {table_name}')

    select_response = await crate.query(f'select * from {table_name}')
    print(select_response.as_table())
    # SQLResponse(error=None, columns=[], row_count=1, duration=8.724443)

asyncio.run(main())
```

## Style guide
This project uses Google Python Style guide with minor tweaks, enforced by pyling, read more in
* Google documentation: https://google.github.io/styleguide/pyguide.html
* Docstring documentation: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html

### Tweaks
* Max line is 100
* Indentation is four spaces.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cratedb-async",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "connector, cratedb, database, driver, http",
    "author": null,
    "author_email": "surister <surister98@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/64/7b/c52a453763688600d1b4012535c5dbd2faabc1b0c58ba007baf88627f41d/cratedb_async-0.0.8.tar.gz",
    "platform": null,
    "description": "# CrateDB Async driver based on httpx.\n![PyPI - Version](https://img.shields.io/pypi/v/cratedb-async)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cratedb-async)\n![PyPI - License](https://img.shields.io/pypi/l/cratedb-async)\n![PyPI - Status](https://img.shields.io/pypi/status/cratedb-async)\n[![Upload](https://github.com/surister/cratedb-async/actions/workflows/python-publish.yml/badge.svg)](https://github.com/surister/cratedb-async/actions/workflows/python-publish.yml)\n\nAsynchronous driver for CrateDB, it uses the HTTP protocol and follows its own design.\n\n## Usage\n\nIt can be used with any async library:\n\n#### Asyncio\n```python\n\nimport asyncio\n\nfrom cratedb_async.client import CrateClient\n\n\nasync def main():\n    crate = CrateClient('http://192.168.88.251:4200')\n    response = await crate.query('SELECT * FROM sys.summits')\n    print(response.as_table())\n\nasyncio.run(main())\n\n# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+\n# | classification | coordinates         | country | first_ascent | height | mountain       | prominence | range         | region               |\n# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+\n# | I/B-07.V-B     | [6.86444, 45.8325]  | FR/IT   | 1786         | 4808   | Mont Blanc     | 4695       | U-Savoy/Aosta | Mont Blanc massif    |\n# | I/B-09.III-A   | [7.86694, 45.93694] | CH      | 1855         | 4634   | Monte Rosa     | 2165       | Valais        | Monte Rosa Alps      |\n# | I/B-09.V-A     | [7.85889, 46.09389] | CH      | 1858         | 4545   | Dom            | 1046       | Valais        | Mischabel            |\n# | I/B-09.III-A   | [7.83556, 45.92222] | CH/IT   | 1861         | 4527   | Liskamm        | 376        | Valais/Aosta  | Monte Rosa Alps      |\n# | I/B-09.II-D    | [7.71583, 46.10139] | CH      | 1861         | 4506   | Weisshorn      | 1235       | Valais        | Weisshorn-Matterhorn |\n# | I/B-09.II-A    | [7.65861, 45.97639] | CH/IT   | 1865         | 4478   | Matterhorn     | 1042       | Valais/Aosta  | Weisshorn-Matterhorn |\n# | I/B-09.II-C    | [7.61194, 46.03417] | CH      | 1862         | 4357   | Dent Blanche   | 915        | Valais        | Weisshorn-Matterhorn |\n# | I/B-09.I-B     | [7.29917, 45.9375]  | CH      | 1859         | 4314   | Grand Combin   | 1517       | Valais        | Grand Combin Alps    |\n# | I/B-12.II-A    | [8.12611, 46.53722] | CH      | 1829         | 4274   | Finsteraarhorn | 2280       | Bern/Valais   | Bernese Alps         |\n# | I/B-09.II-D    | [7.69028, 46.065]   | CH      | 1864         | 4221   | Zinalrothorn   | 490        | Valais        | Weisshorn-Matterhorn |\n# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+\n```\n\n\n#### Trio\n\n```python\nimport trio\n\nfrom cratedb_async.client import CrateClient\n\n\nasync def main():\n    crate = CrateClient('http://192.168.88.251:4200')\n    response = await crate.query('SELECT * FROM sys.summits')\n    print(response.as_table())\n\ntrio.run(main)\n\n# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+\n# | classification | coordinates         | country | first_ascent | height | mountain       | prominence | range         | region               |\n# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+\n# | I/B-07.V-B     | [6.86444, 45.8325]  | FR/IT   | 1786         | 4808   | Mont Blanc     | 4695       | U-Savoy/Aosta | Mont Blanc massif    |\n# | I/B-09.III-A   | [7.86694, 45.93694] | CH      | 1855         | 4634   | Monte Rosa     | 2165       | Valais        | Monte Rosa Alps      |\n# | I/B-09.V-A     | [7.85889, 46.09389] | CH      | 1858         | 4545   | Dom            | 1046       | Valais        | Mischabel            |\n# | I/B-09.III-A   | [7.83556, 45.92222] | CH/IT   | 1861         | 4527   | Liskamm        | 376        | Valais/Aosta  | Monte Rosa Alps      |\n# | I/B-09.II-D    | [7.71583, 46.10139] | CH      | 1861         | 4506   | Weisshorn      | 1235       | Valais        | Weisshorn-Matterhorn |\n# | I/B-09.II-A    | [7.65861, 45.97639] | CH/IT   | 1865         | 4478   | Matterhorn     | 1042       | Valais/Aosta  | Weisshorn-Matterhorn |\n# | I/B-09.II-C    | [7.61194, 46.03417] | CH      | 1862         | 4357   | Dent Blanche   | 915        | Valais        | Weisshorn-Matterhorn |\n# | I/B-09.I-B     | [7.29917, 45.9375]  | CH      | 1859         | 4314   | Grand Combin   | 1517       | Valais        | Grand Combin Alps    |\n# | I/B-12.II-A    | [8.12611, 46.53722] | CH      | 1829         | 4274   | Finsteraarhorn | 2280       | Bern/Valais   | Bernese Alps         |\n# | I/B-09.II-D    | [7.69028, 46.065]   | CH      | 1864         | 4221   | Zinalrothorn   | 490        | Valais        | Weisshorn-Matterhorn |\n# +----------------+---------------------+---------+--------------+--------+----------------+------------+---------------+----------------------+\n\n```\n\n#### Bulk insert\n\n```python\nimport asyncio\n\nfrom cratedb_async.client import CrateClient\n\n\nasync def main():\n    crate = CrateClient('http://192.168.88.251:4200')\n    rows = [\n        ('one', 2, ['three', ]),\n        ('three', 4, ['five', ])\n    ]\n    table_name = 'my_tbl'\n    \n    create_table_resp = await crate.query(f'create table {table_name} (one text, two integer, three array(TEXT))')\n    print(create_table_resp)\n    # SQLResponse(error=None, columns=[], row_count=1, duration=177.55101)\n\n    response = await crate.bulk_insert(table_name, rows)\n    print(response)\n    # SQLResponse(error=None, columns=[], row_count=0, duration=6.341763)\n\n    await crate.query(f'refresh table {table_name}')\n\n    select_response = await crate.query(f'select * from {table_name}')\n    print(select_response.as_table())\n    # SQLResponse(error=None, columns=[], row_count=1, duration=8.724443)\n\nasyncio.run(main())\n```\n\n## Style guide\nThis project uses Google Python Style guide with minor tweaks, enforced by pyling, read more in\n* Google documentation: https://google.github.io/styleguide/pyguide.html\n* Docstring documentation: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html\n\n### Tweaks\n* Max line is 100\n* Indentation is four spaces.\n",
    "bugtrack_url": null,
    "license": "Copyright 2025 github.com/surister  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Asynchronous http driver for CrateDB",
    "version": "0.0.8",
    "project_urls": null,
    "split_keywords": [
        "connector",
        " cratedb",
        " database",
        " driver",
        " http"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "343bd64ca37dd65eccd6b85fb7a4574c4b865aafc43ce75d400a9354e2d85b50",
                "md5": "dcc1b808a2b629d5fc015d9856773945",
                "sha256": "b4caa305ef50c1fec149b454ab88461cb0ed4ff3de8e70888b0e1e24ba5f520e"
            },
            "downloads": -1,
            "filename": "cratedb_async-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dcc1b808a2b629d5fc015d9856773945",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 7362,
            "upload_time": "2025-09-08T08:29:20",
            "upload_time_iso_8601": "2025-09-08T08:29:20.625932Z",
            "url": "https://files.pythonhosted.org/packages/34/3b/d64ca37dd65eccd6b85fb7a4574c4b865aafc43ce75d400a9354e2d85b50/cratedb_async-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "647bc52a453763688600d1b4012535c5dbd2faabc1b0c58ba007baf88627f41d",
                "md5": "116c38158167567d7292330e90b7dfdf",
                "sha256": "1c8446d4519097cfa248d5067e9757f3f225867e65e81c71dd717d7219fae7d8"
            },
            "downloads": -1,
            "filename": "cratedb_async-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "116c38158167567d7292330e90b7dfdf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 24609,
            "upload_time": "2025-09-08T08:29:21",
            "upload_time_iso_8601": "2025-09-08T08:29:21.362575Z",
            "url": "https://files.pythonhosted.org/packages/64/7b/c52a453763688600d1b4012535c5dbd2faabc1b0c58ba007baf88627f41d/cratedb_async-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-08 08:29:21",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cratedb-async"
}
        
Elapsed time: 2.16175s