> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slai.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting to Google BigQuery

> Slai supports direct integration with Google BigQuery. This guide demonstrates how to retrieve data from BigQuery for use in a Slai Sandbox.

## Connecting an Integration

Let's start by setting up the integration.

Integrations live at the root level of Slai, which makes them accessible from any sandbox in your account. To create an integration, click the **Integrations** tab on the sidebar on [your dashboard](https://slai.io/models).

<img src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/connect-integration.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=7c60f4e9af2cd6b0ac2c142f7f26d8a9" alt="Connect Integration" width="252" height="342" data-path="img/integrations/bigquery/connect-integration.png" />

You'll be presented with a list of existing integrations, if any exist. Click **Add Integration** to create a new one.

<img src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/add-integration-bigquery.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=7d4449a87876313827e2a90699db6204" alt="Add Integration BigQuery" width="1414" height="702" data-path="img/integrations/bigquery/add-integration-bigquery.png" />

You'll be prompted to enter a **Name** and [Service Account Credentials](https://cloud.google.com/iam/docs/creating-managing-service-accounts) in order to allow our app to query your database.

We recommend creating a new **Service Account** and setting strict **BigQuery** access in your Google Cloud Console.

<img src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/bigquery-service-account.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=2eaa4ec5a7d6b4e9074c36f19700dfd4" alt="BigQuery Service Account" width="1270" height="1132" data-path="img/integrations/bigquery/bigquery-service-account.png" />

Click **Create Connection** to add the integration to your list

## Creating a query in your sandbox

To access your BigQuery database in your project, you must add the integration in the sandbox. In the left-hand side of the sandbox, click the **+** button and select **Import from Integration**.

<div class="flex justify-center space-x-4">
  <img class="h-80" src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/plus-button-import.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=3a33e9607dbed14a4076184b72b2973d" width="440" height="602" data-path="img/integrations/bigquery/plus-button-import.png" />

  <img class="h-80" src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/import-from-integration-bigquery.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=3ae78c52779f9c568fe38316be4e0ad2" width="438" height="602" data-path="img/integrations/bigquery/import-from-integration-bigquery.png" />
</div>

You will be prompted to select an integration, so select your BigQuery integration,
and click **Select Integration**.

<img src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/select-integration-bigquery.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=19eae03aa08962fdccf186db77fcc3e0" alt="Select Integration" width="908" height="596" data-path="img/integrations/bigquery/select-integration-bigquery.png" />

You will be prompted to enter a **Query Name** (which is how you'll reference the saved query in training) and the **Query** (which is your raw query to the database). Click **Import** to continue.

<img src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/import-data-bigquery.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=ff7e8f3efdcb78891101c89a1806c69e" alt="Import Data BigQuery" width="950" height="932" data-path="img/integrations/bigquery/import-data-bigquery.png" />

Once you import the integration, you will see your **BigQuery** integration appear in your data section. You can add multiple queries from the same integration in your sandbox.

## Using the query data in the sandbox

After the query is attached to your sandbox, it will be stored as a file named `results.csv` that can be accessed like a regular file in your code.

The general file path will look something like `./integrations/bigquery/[query_name]/results.csv`.

Alternatively, you can copy the path to your clipboard by right-clicking the query and clicking `Copy Path`.

<img class="h-80" src="https://mintcdn.com/slai-docs/0GTBstnyDK-8Z9OV/img/integrations/bigquery/copy-path-bigquery.png?fit=max&auto=format&n=0GTBstnyDK-8Z9OV&q=85&s=6b2bfaf5d8639d3227bfca93e0c10ce5" width="484" height="496" data-path="img/integrations/bigquery/copy-path-bigquery.png" />
