Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

A Python wrapper for the KSql REST API

Project Description

ksql-python
===========

A python wrapper for the KSQL REST API. Easily interact with the KSQL REST API using this library.

.. image:: https://travis-ci.org/bryanyang0528/ksql-python.svg?branch=master
:target: https://travis-ci.org/bryanyang0528/ksql-python

.. image:: https://codecov.io/gh/bryanyang0528/ksql-python/branch/master/graph/badge.svg
:target: https://codecov.io/gh/bryanyang0528/ksql-python

Installation
------------

.. code:: bash

pip install ksql

Or

.. code:: bash

git clone https://github.com/bryanyang0528/ksql-python
cd ksql-python
python setup.py install

Getting Started
---------------

This is the GITHUB page of KSQL. https://github.com/confluentinc/ksql

Setup
~~~~~

- Setup for the KSql API:

.. code:: python

from ksql import KSQLAPI
client = KSQLAPI('http://ksql-server:8080')

Options
~~~~~~~

+---------------+-----------+------------+--------------------------------------------------------------+
| Option | Type | Required | Description |
+===============+===========+============+==============================================================+
| ``url`` | string | yes | Your ksql-server url. Example: ``http://ksql-server:8080`` |
+---------------+-----------+------------+--------------------------------------------------------------+
| ``timeout`` | integer | no | Timout for Requests. Default: ``5`` |
+---------------+-----------+------------+--------------------------------------------------------------+

Main Methods
~~~~~~~~~~~~

ksql
^^^^

.. code:: python

client.ksql('show tables')

- Example Response ``[{'tables': {'statementText': 'show tables;', 'tables': []}}]``

query
^^^^^

It will execute sql query and keep listening streaming data.

.. code:: python

client.query('select * from table1')

- Example Response

::

{"row":{"columns":[1512787743388,"key1",1,2,3]},"errorMessage":null}
{"row":{"columns":[1512787753200,"key1",1,2,3]},"errorMessage":null}
{"row":{"columns":[1512787753488,"key1",1,2,3]},"errorMessage":null}
{"row":{"columns":[1512787753888,"key1",1,2,3]},"errorMessage":null}

Simplified API
~~~~~~~~~~~~~~

create_stream/ create_table
^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

client.create_stream(table_name=table_name,
columns_type=columns_type,
topic=topic,
value_format=value_format)

Options
^^^^^^^

+-----------------+-----------+----------+--------------------------------------------------------------+
| Option | Type | Required | Description |
+=================+===========+==========+==============================================================+
| ``table_name`` | string | yes | Your ksql-server url. Example: ``http://ksql-server:8080`` |
+-----------------+-----------+----------+--------------------------------------------------------------+
| ``columns_type``| list | yes | ex:``['viewtime bigint','userid varchar','pageid varchar']`` |
+-----------------+-----------+----------+--------------------------------------------------------------+
| ``topic`` | string | yes | Kafka topic |
+-----------------+-----------+----------+--------------------------------------------------------------+
| ``value_format``| string | no | ``DELIMITED``(Default) or ``JSON`` |
+-----------------+-----------+----------+--------------------------------------------------------------+

- Responses
:Situation:
Response

:If create table/stream succeed:
return True

:If failed:
raise a CreatError(respose_from_ksql_server)

Release History

This version
History Node

0.3.0.2.22

History Node

0.3.0.2.21

History Node

0.3.0.1.2

History Node

0.3.0.1.1

History Node

0.2.2.0

History Node

0.2.1.1

History Node

0.2.1

History Node

0.2.0

History Node

0.2.0rc0

History Node

0.2.0b0

History Node

0.2.0a0

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
ksql-0.3.0.2.22.tar.gz
(6.5 kB) Copy SHA256 Hash SHA256
Source None Jan 11, 2018

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting