Requirements and setup

In this tutorial, we will connect to Starburst Galaxy and verify our connection. Following tutorials will go through the basics of Ibis on Starburst Galaxy’s demo data.

Prerequisites

You need a Python environment with Ibis installed and a Starburst Galaxy account.

Connect to Starburst Galaxy

First, connect to Starburst Galaxy. We’ll use a .env in this example for secrets that are loaded as environment variables. This requires installing the python-dotenv package – alternatively, you can set the environment variables for your system.

Tip

Hover over (or click on mobile) the numbers in the code blocks to see tips and explanations.

import os
import ibis
from dotenv import load_dotenv

ibis.options.interactive = True

load_dotenv()

user = os.getenv("USERNAME")
password = os.getenv("PASSWORD")
host = os.getenv("HOSTNAME")
port = os.getenv("PORTNUMBER")
catalog = "sample"
schema = "demo"

con = ibis.trino.connect(
    user=user, password=password, host=host, port=port, database=catalog, schema=schema
)
con
1
Import necessary libraries.
2
Use Ibis in interactive mode.
3
Load environment variables.
4
Load secrets from environment variables.
5
Use the sample demo data.
6
Connect to Starburst Galaxy.
7
Display the connection object.
<ibis.backends.trino.Backend at 0x13f48e850>

Verify connection

List the tables your connection has:

con.list_tables()
['astronauts', 'missions']

Run a SQL query:

con.sql("select 1 as a")
┏━━━━━━━┓
┃ a     ┃
┡━━━━━━━┩
│ int32 │
├───────┤
│     1 │
└───────┘

If you have any issues, check your connection details above. If you are still having issues, open an issue on Ibis and we’ll do our best to help you!

Next steps

Now that you’re connected to Starburst Galaxy, you can continue this tutorial to learn the basics of Ibis or query your own data. See the rest of the Ibis documentation or Starburst Galaxy documentation. You can open an issue if you run into one!

Back to top