KSQLdb for Python
Project Overview
A Python wrapper for the KSQLdb REST API
Installation
pip install ksqldb
Client configuration
from ksqldb import KSQLdbClient
client = KSQLdbClient('http://localhost:8088')
It can also be configured with Basic authentication:
from ksqldb import KSQLdbClient
client = KSQLdbClient('http://localhost:8088', api_key="<KEY>", api_secret="<SECRET>")
Usage
client.get_properties()
Returns KSQLdb properties
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
Examples of executing KSQL statements:
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:
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:
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.
client.close_query("QUERY_ID")
inserts_stream(stream_name, rows)
Inserts data into a stream.
rows = [
{
"col1" : "val1",
"col2": 2.3,
"col3": True
},
{
"col1" : "val1",
"col2": 2.3,
"col3": True
},
]
client.inserts_stream("STREAM_NAME", rows)
Metadata
Release files for ksqldb 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ksqldb-1.0.1.tar.gz | 4.1 kB | Without provenance | Details for ksqldb-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ksqldb-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for ksqldb-1.0.1-py3-none-any.whl |
Total release size: 9.3 kB
Release files / ksqldb-1.0.1.tar.gz
| Download URL | ksqldb-1.0.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f257388ae5c70f5d8166526d5c6846734c36855df216825b381c48201a4b8d55
|
|
BLAKE2b-256 checksum How to use checksums |
d6c1efaaa27ffa2f37930712f30802501250616e1387ffae2d0d9da797a2b7d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / ksqldb-1.0.1-py3-none-any.whl
| Download URL | ksqldb-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7c7833e5d571234120e4fb2f696df04a1d4a3f9ea78e1172aee509483198b38
|
|
BLAKE2b-256 checksum How to use checksums |
237fd5a7a92c716466bf9dc81627696c0f2574e86a3199973e95e48efbf658a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for ksqldb 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.