Skip to content

Get Started with RAI in a Cloud Notebook

You can use RelationalAI in cloud notebook environments like Google Colab or Hex. Click on the tabs below to see the instructions for each cloud notebook environment.

Paste the following code into a Google Colab cell and press ++shift+enter++ to run it:

%pip install relationalai

Note that the percent sign % marks the command as a shell command in Colab.

Click on the key icon in the left sidebar to open the user secrets editor. Add your password with the key snowflake_password. Then, fill in the following code snippet with your Snowflake account details and execute it to create a RAI model and connect to your Snowflake account:

import relationalai as rai
from google.colab import userdata
rai.save_config(f"""
account = "<SNOWFLAKE_ACCOUNT>"
user = "<SNOWFLAKE_USER>"
password = {userdata.get('snowflake_password')}
role = "<SNOWFLAKE_ROLE>"
warehouse = "<SNOWFLAKE_WAREHOUSE>"
""")

Verify that the relationalai package is installed and working correctly by running the following code:

import relationalai as rai
# Create a model named "MyFirstModel".
model = rai.Model("MyFirstModel")
# Send a test query.
with model.query() as select:
response = select(1 + 1)
# The results are stored as a pandas DataFrame in the response.results attribute.
print(response.results)
# v
# 0 2