Streambased Documentation
  • Home
  • Overview
    • Key Concepts
  • Streambased Cloud
    • Streambased Cloud UI
      • Create your first Streambased cluster
      • Create your first Streambased API Key
      • Running your first A.S.K Query
      • Exploring your data using S.S.K
    • Iceberg Service for Kafka - I.S.K.
      • Overview
      • Architecture
      • Usage
      • Quick Start
    • Analytics Service for Kafka - A.S.K.
      • Overview
      • Architecture
      • Connecting to Streambased A.S.K.
        • Connect Superset to Streambased A.S.K.
        • Connect Jupyter to Streambased A.S.K.
        • Connect a JDBC Client to Streambased A.S.K.
        • Connect an ODBC client to Streambased A.S.K.
        • Connect a Python Application (SQL Alchemy) to Streambased A.S.K.
    • Storage Service for Kafka - S.S.K.
      • Overview
      • Connecting to Streambased S.S.K.
        • Connecting a S3 compatible client to Streambased S.S.K.
        • Connect a S3manager to Streambased S.S.K.
  • Streambased Platform
    • Overview
    • Requirements
    • Step by Step Installation
    • Configuration
    • Connecting Analytical Applications to Streambased
      • Connect Superset to Streambased
      • Connect Jupyter to Streambased
      • Connect a JDBC Client to Streambased
      • Connect an ODBC client to Streambased
      • Connect a Python Application (SQL Alchemy) to Streambased
Powered by GitBook
On this page
  • Prerequisites:
  • Step 1: Create a python application
  • Step 2: Experiment
  1. Streambased Platform
  2. Connecting Analytical Applications to Streambased

Connect a Python Application (SQL Alchemy) to Streambased

The Python programming language has a number of powerful libraries like Pandas for data manipulation and analytics workloads. Let's add some real-time data.

PreviousConnect an ODBC client to Streambased

Last updated 3 months ago

Prerequisites:

  • A running Streambased instance, for instructions see

  • A Python installation with the following extra packages:

    • sqlalchemy-trino

Step 1: Create a python application

The following sample code show how to integrate python with Streambased cloud:

import sqlalchemy

from sqlalchemy as db
server_host='[server host]'
server_port='[server port]'
engine = sqlalchemy.create_engine(f"trino://{server_host}:{server_port}/kafka",
                       connect_args ={"schema":"streambased"})

conn = engine.connect() 
query = "select * from purchases limit 100"
exe = conn.execute(query) 
result = exe.fetchmany(5) 
print(result)

By default server port is 8080 and server host is the name of the host on which the docker instance has been launched.

Step 2: Experiment

Change the query variable to execute different statement in your python environment

here