Skip to main content

High level Python API for writing to Kafka

Project description

Welcome to Py2k

Tests codecov pypi downloads versions license

A high level Python to Kafka API with Schema Registry compatibility and automatic avro schema creation.

  • Free software: Apache2 license

Installation

Py2K is currently available on PIP:

pip install py2k

Documentation

You can view additional documentation on our website.

Contributing

Please see the Contribution Guide for more information.

Usage

Minimal Example

from py2k.record import PandasToRecordsTransformer
from py2k.writer import KafkaWriter

# assuming we have a pandas DataFrame, df
records = PandasToRecordsTransformer(df=df, record_name='test_model').from_pandas()

writer = KafkaWriter(
    topic="topic_name",
    schema_registry_config=schema_registry_config,
    producer_config=producer_config
)

writer.write(records)

For additional examples please see the examples folder

Features

  • Schema Registry Integration
  • Automatic Avro Serialization from pandas DataFrames
  • Automatic Avro Schema generation from pandas DataFrames and Pydantic objects

License

Copyright 2021 ABSA Group Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Release Notes

Latest Changes

v1.9.1 (2021-10-04)

Bug

  • 🐛 Kafka Schema was not extracted from entire Dataframe. #76 - @vesely-david

v1.9.0 (2021-05-15)

Enhancement

  • ✨ Support for dynamic creation to return an iterator. #67 - @vesely-david

    • User can choose whether to return list (from_pandas) or iterator (iter_from_pandas)
    • KafkaWriter was adjusted accordingly to accept any iterable in it's write method

v1.8.2 (2021-04-06)

Bugs

  • Resolved boolean schema not being converted to the correct avro schema values PR #48 - @vesely-david

v1.8.1 (2021-03-31)

Docs

v1.8.0 (2021-03-29)

Fixes

  • Adhering to Kafka and Avro parlance by renaming:
    • models module -> record
    • KafkaModel -> KafkaRecord
    • DynamicPandasModel -> PandasToRecordsTransformer
    • item -> record
  • Move schema knowledge to KafkaRecord
  • Introduce __key_fields__ in KafkaRecord to enable specifying which fields are part of the key
  • Introduce __include_key__ in KafkaRecord to enable specifying whether key_fields should be part of the value message

Big thank you to @vesely-david for this change

v1.7.0 (2021-03-11)

  • Minor API change for easier dynamic creation of KafkaModels from a pandas DataFrame

v1.6.0 (2021-03-01)

  • First commit on Github.

Project details


Download files

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

Source Distribution

py2k-1.9.1.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py2k-1.9.1-py2.py3-none-any.whl (17.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file py2k-1.9.1.tar.gz.

File metadata

  • Download URL: py2k-1.9.1.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for py2k-1.9.1.tar.gz
Algorithm Hash digest
SHA256 3b724b4adb17e48a5fe4049602d7a5e774322ec9286568015149efff2f455e14
MD5 817a3194f850aca35db03cc524ddedaa
BLAKE2b-256 2e02419fdd2e99129131fd2cd53ccf3ca82df52a906c8d9a341b30db74529990

See more details on using hashes here.

File details

Details for the file py2k-1.9.1-py2.py3-none-any.whl.

File metadata

  • Download URL: py2k-1.9.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for py2k-1.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 675793e0e3fea042c0924e92cd4887b7707df9134aac5eec2fed8f6f7184b714
MD5 941e62519049c554d6c09c254e814018
BLAKE2b-256 55a9e7b67e201746d875d7d3aed3a8e64095c84f2766c0f5d4c0ed1c68e8d66a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page