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
      • Dynamic 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: Fetch your login credentials
  • Step 2: Create a python application
  • Step 3: Experiment
  1. Streambased Cloud
  2. Analytics Service for Kafka - A.S.K.
  3. Connecting to Streambased A.S.K.

Connect a Python Application (SQL Alchemy) to Streambased A.S.K.

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 A.S.K.NextStorage Service for Kafka - S.S.K.

Last updated 3 months ago

Prerequisites:

  • An active Streambased Cloud account, sign up or log in

  • A Python installation with the following extra packages:

    • sqlalchemy-trino

Step 1: Fetch your login credentials

Access to Streambased Cloud is managed via API-keys, you can create one for you new connection

With sqlalchemy you will use your public key as the database username and your secret key as the database password. Make a note of these for Step 2.

Step 2: Create a python application

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

import sqlalchemy

from sqlalchemy as db
username='[public key from step 1]'
password='[secret key from step 1]'
engine = sqlalchemy.create_engine(f"trino://{username}:{password}@ask-beta.streambased.cloud:8443/kafka",
                       connect_args ={"http_scheme":"https", "schema":"streambased"})


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

Step 3: Experiment

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

here
here