ksqldb


Nameksqldb JSON
Version 1.0.1 PyPI version JSON
download
home_page
SummaryA simple Python wrapper for the KSQLdb REST API
upload_time2023-01-11 22:32:16
maintainer
docs_urlNone
authorVictor Grosu
requires_python>=3.7
licenseMIT License Copyright (c) 2023 Victor Grosu 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 ksql ksqldb kafka
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">KSQLdb for Python</h1>


## Project Overview

A Python wrapper for the KSQLdb REST API


## Installation

    pip install ksqldb

## Client configuration

```python
from ksqldb import KSQLdbClient

client = KSQLdbClient('http://localhost:8088')
```
It can also be configured with Basic authentication:

```python
from ksqldb import KSQLdbClient

client = KSQLdbClient('http://localhost:8088', api_key="<KEY>", api_secret="<SECRET>")
```

## Usage

### `client.get_properties()`
Returns KSQLdb properties
```python
client.get_properties()
```

### `client.ksql(ksql_string, stream_properties=None)`
For a full list of statement options make sure to check KSQLdb API: [/ksql endpoint](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/ksql-endpoint/)

Examples of executing KSQL statements:
```python
client.ksql("show topics;")
client.ksql("show streams;")
client.ksql("show tables;")
client.ksql("describe <STREAM_NAME> extended;")
```

### `client.query_sync(query_string, stream_properties=None, timeout=10)`
Runs a query **synchronously**.
Can't be used with `EMIT CHANGES` queries.

Examples of executing KSQL queries:
```python
client.query_sync("select * from STREAM_NAME;")

# To get data from beginning of stream use: 
client.query_sync("select * from STREAM_NAME;", stream_properties={"ksql.streams.auto.offset.reset": "earliest"})
```

### `client.query_async(query_string, stream_properties=None, timeout=10)`
Runs a query **asynchronously**.

To test this in python shell can use `python -m asyncio`
Examples of executing KSQL async queries:
```python
async for x in client.query_async("select * from STREAM_NAME emit changes;", timeout=None):
    print(x)
    
# To get data from beginning of stream use: 
async for x in client.query_async("select * from STREAM_NAME emit changes;", stream_properties={"ksql.streams.auto.offset.reset": "earliest"}, timeout=None):
    print(x)
```

### `close_query(query_id)`
Usually you don't need to close a sync query, but should be done for **async** ones.

```python
client.close_query("QUERY_ID")
```

### `inserts_stream(stream_name, rows)`
Inserts data into a stream.

```python
rows = [
    {
        "col1" : "val1",
        "col2": 2.3,
        "col3": True
    },
    {
        "col1" : "val1",
        "col2": 2.3,
        "col3": True
    },
]
client.inserts_stream("STREAM_NAME", rows)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ksqldb",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "ksql,ksqldb,kafka",
    "author": "Victor Grosu",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/d6/c1/efaaa27ffa2f37930712f30802501250616e1387ffae2d0d9da797a2b7d4/ksqldb-1.0.1.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">KSQLdb for Python</h1>\n\n\n## Project Overview\n\nA Python wrapper for the KSQLdb REST API\n\n\n## Installation\n\n    pip install ksqldb\n\n## Client configuration\n\n```python\nfrom ksqldb import KSQLdbClient\n\nclient = KSQLdbClient('http://localhost:8088')\n```\nIt can also be configured with Basic authentication:\n\n```python\nfrom ksqldb import KSQLdbClient\n\nclient = KSQLdbClient('http://localhost:8088', api_key=\"<KEY>\", api_secret=\"<SECRET>\")\n```\n\n## Usage\n\n### `client.get_properties()`\nReturns KSQLdb properties\n```python\nclient.get_properties()\n```\n\n### `client.ksql(ksql_string, stream_properties=None)`\nFor a full list of statement options make sure to check KSQLdb API: [/ksql endpoint](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/ksql-endpoint/)\n\nExamples of executing KSQL statements:\n```python\nclient.ksql(\"show topics;\")\nclient.ksql(\"show streams;\")\nclient.ksql(\"show tables;\")\nclient.ksql(\"describe <STREAM_NAME> extended;\")\n```\n\n### `client.query_sync(query_string, stream_properties=None, timeout=10)`\nRuns a query **synchronously**.\nCan't be used with `EMIT CHANGES` queries.\n\nExamples of executing KSQL queries:\n```python\nclient.query_sync(\"select * from STREAM_NAME;\")\n\n# To get data from beginning of stream use: \nclient.query_sync(\"select * from STREAM_NAME;\", stream_properties={\"ksql.streams.auto.offset.reset\": \"earliest\"})\n```\n\n### `client.query_async(query_string, stream_properties=None, timeout=10)`\nRuns a query **asynchronously**.\n\nTo test this in python shell can use `python -m asyncio`\nExamples of executing KSQL async queries:\n```python\nasync for x in client.query_async(\"select * from STREAM_NAME emit changes;\", timeout=None):\n    print(x)\n    \n# To get data from beginning of stream use: \nasync for x in client.query_async(\"select * from STREAM_NAME emit changes;\", stream_properties={\"ksql.streams.auto.offset.reset\": \"earliest\"}, timeout=None):\n    print(x)\n```\n\n### `close_query(query_id)`\nUsually you don't need to close a sync query, but should be done for **async** ones.\n\n```python\nclient.close_query(\"QUERY_ID\")\n```\n\n### `inserts_stream(stream_name, rows)`\nInserts data into a stream.\n\n```python\nrows = [\n    {\n        \"col1\" : \"val1\",\n        \"col2\": 2.3,\n        \"col3\": True\n    },\n    {\n        \"col1\" : \"val1\",\n        \"col2\": 2.3,\n        \"col3\": True\n    },\n]\nclient.inserts_stream(\"STREAM_NAME\", rows)\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Victor Grosu  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.",
    "summary": "A simple Python wrapper for the KSQLdb REST API",
    "version": "1.0.1",
    "split_keywords": [
        "ksql",
        "ksqldb",
        "kafka"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "237fd5a7a92c716466bf9dc81627696c0f2574e86a3199973e95e48efbf658a5",
                "md5": "c735e1eccbf6b03bb073ab2e285d52b4",
                "sha256": "c7c7833e5d571234120e4fb2f696df04a1d4a3f9ea78e1172aee509483198b38"
            },
            "downloads": -1,
            "filename": "ksqldb-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c735e1eccbf6b03bb073ab2e285d52b4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5181,
            "upload_time": "2023-01-11T22:32:14",
            "upload_time_iso_8601": "2023-01-11T22:32:14.671026Z",
            "url": "https://files.pythonhosted.org/packages/23/7f/d5a7a92c716466bf9dc81627696c0f2574e86a3199973e95e48efbf658a5/ksqldb-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d6c1efaaa27ffa2f37930712f30802501250616e1387ffae2d0d9da797a2b7d4",
                "md5": "dcb610d92759fd48ea9e2c7869027b5a",
                "sha256": "f257388ae5c70f5d8166526d5c6846734c36855df216825b381c48201a4b8d55"
            },
            "downloads": -1,
            "filename": "ksqldb-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "dcb610d92759fd48ea9e2c7869027b5a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4143,
            "upload_time": "2023-01-11T22:32:16",
            "upload_time_iso_8601": "2023-01-11T22:32:16.578734Z",
            "url": "https://files.pythonhosted.org/packages/d6/c1/efaaa27ffa2f37930712f30802501250616e1387ffae2d0d9da797a2b7d4/ksqldb-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-11 22:32:16",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "ksqldb"
}
        
Elapsed time: 0.03672s