May 23, 2023

How to Connect & Analyze Data using Ibis in Snowflake

Fernanda Foertter and Kae Suarez

view of skyscraper from ground looking up

For businesses that need to analyze large amounts of data, traditional analytics engines are not enough. The Hadoop era of the last 15 years brought us many alternative analytics engines like Apache Impala and Trino. These provide faster, flexible, and scalable querying capabilities. However, connecting to these engines can be challenging, especially if you are not familiar with their configuration or special flavor querying language. Learning how to access data in these systems or hiring an expert may take time — and agility matters in making business decisions. We show how Ibis can be a Python frontend to connect to analytics engines.

The Ibis Project is a Python-based data analysis framework that makes it easy to connect to 18 analytics engines from on-premises all the way to powerful cloud resources like Snowflake. In this blog post, we will discuss how to use Ibis to connect to and analyze data using Snowflake.

Installing Ibis

The first step is to install Ibis. You can install Ibis using pip, Python’s package manager. Open your command prompt and run the following command:

pip install 'ibis-framework[snowflake]'

This will install the latest version of Ibis.

Connecting to Snowflake

Once you have installed Ibis, you can use it to connect to Snowflake. In order to do this, you will need to have your credentials and target, then just pass those into Ibis:

import ibis

con = ibis.snowflake.connect(
    user='username',
    password='mypassword',
    account='myaccount',
    database='mydatabase'
)

This code will create a connection to Snowflake from your local machine.

Analyzing Data

Now that you have a connection to Snowflake, you can start analyzing data. Ibis allows you to create tables and run queries against them. For example, you can create a table using the following code:

t = con.table('my_table')

This will create a table object that you can use to run queries against.

You can run queries using the execute method. For example, to count the number of rows in the table, you can use the following code:

result = t.count().execute()
print(result)

This will print the number of rows in the table.

You’re ready to go with running analytics without having to learn a new interface! Getting started with cloud technologies like Snowflake can be challenging, but Ibis makes it easy. With Ibis, you can quickly connect to Snowflake and start analyzing data all while staying in the same Python ecosystem. If you need to analyze large amounts of data, Ibis and Snowflake provide a powerful solution, helping your organization save money and time.

Voltron Data helps companies adopt tools like Ibis to maximize business value faster and more efficiently. If you want to see how we can help your business, explore Voltron Data Enterprise Support.

Photo by Verne Ho