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.
Prerequisites:
A running Streambased instance, for instructions see here
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)
Step 2: Experiment
Change the query
variable to execute different statement in your python environment
Last updated