Connect Jupyter to Streambased A.S.K.

Jupyter notebooks are used for exploratory data analysis, data cleaning, data visualization, statistical modeling, machine learning, and deep learning. Let's bring real-time data into the mix.

Prerequisites:

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

  • A running Jupyter deployment that has the following additional packages:

    • jupysql

    • 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 here

With Jupyter 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 database engine

In a new notebook execute the following:

from sqlalchemy.engine import create_engine
engine = create_engine("trino://[username]:[password]@ask-beta.streambased.cloud:8443/kafka",
                       connect_args ={"http_scheme":"https", "schema":"streambased"})

Replace [username] and [password] with the values from Step 1

Step 3: Connect to the database

From your notebook run the following to load the SQL extension and the open the previously created engine:

%load_ext sql
%sql engine

Step 4: Run a query

Using the SQL extension we can execute anything we like. Happy querying!

%sql SELECT * FROM demo_transactions

Last updated