SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Apache Kafka Python Sample: Consuming and Writing Data into SAP HANA Cloud, data lake Files

This tutorial demonstrates how to set up an Apache Kafka instance locally and create Python scripts to produce and consume data into data lake Files based on user specifications.

Overview

🎓 beginner 30 min. SAP HANA Cloud Data LakeIntermediateSAP HANA Cloud

You will learn

  • How to create a Kafka producer script in Python.
  • How to create a Kafka consumer script in Python.
  • How to integrate and write data into SAP HANA Cloud ,data lake files.
Aum Chotaliya A Aum Chotaliya August 20, 2024
Created by August 13, 2024
Contributors

Prerequisites

Prerequisites

  • Apache Kafka installed.
  • Python installed.
  • Basic knowledge of Python and Kafka.
  • Access to SAP Business Technology Platform (BTP) and a provisioned data lake instance (HDLF) with configured certificates. Refer to the SAP HANA Cloud Data Lake Setup for data lake setup and this tutorial for configuring certificates.
  • A running local Kafka server with the address localhost:9092.

Steps

Intro

Apache Kafka is a distributed event streaming platform capable of handling trillions of events a day. In this tutorial, you will use a local Kafka instance and create Python scripts to consume and write data into SAP HANA Cloud, data lake files. Specifically, we will be sending random temperature and timestamp data, which will be processed and stored in the data lake in csv format.


Step 1 Set Up Local Apache Kafka Instance

Ensure that you have a local Apache Kafka instance up and running. If not, you can set up Kafka on your local machine by following the official Kafka Quickstart Guide.

To follow this tutorial smoothly, you need to create a Kafka topic named KafkaDemo:

Shell
kafka-topics.sh --create --topic KafkaDemo --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1
Step 2 Setting Up Producer Code
+
Step 3 Setting Up Consumer Code
+
Step 4 Explore and Experiment!
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 4
1. Set Up Local Apache Kafka Instance 2. Setting Up Producer Code 3. Setting Up Consumer Code 4. Explore and Experiment!

Learn more →