# Connecting to Looker SQL Interface

## **Setting up and testing the connection** <a href="#setting_up_and_testing_the_connection" id="setting_up_and_testing_the_connection"></a>

This section guides you through the essential steps to set up and test your connection in the Looker SQL Interface, ensuring a smooth and successful integration.

### **Prerequisites**

* An active account in the Looker console.
* Ensure your Looker instance is running on version 23.6 or later.
* Activation of the SQL Interface feature on your Looker instance.
* Enable the **SQL Interface Labs** feature on your Looker instance.
* The SQL Interface currently supports only BigQuery connections.
* Users connecting to Looker should at least have **Explore** permission.

### **Limitations**

* Joins aren't supported.
* Timezones aren't supported presently.
* Certain data types, including Geography, JSON, and Time are not supported. Use Timestamp or Datetime for Time.
* Data definition, manipulation, and control are not available.
* Although majority of operators used in BigQuery are supported, some operators and functions available in BigQuery may not be supported identically in Looker.

### **Pre-connection checks**

Before diving into the connection setup, it's crucial to perform preliminary checks to ensure that your database connections are correctly configured and functioning as expected.

* Test the database connections independently of Looker.
* Use a database management tool or a simple script to ensure that the database is accessible and responding to queries.

### **Establishing the connection**

* Connect to the database by entering the necessary connection details such as host URL, port, database name, username, and password in [this link](https://tellius.cloud.looker.com/admin/next/connections).
* Once the connection is established, test the connection using the **"Test connection"** feature in Looker. Look out for confirmation messages or any error logs that might indicate issues.

### **Creating and configuring a Looker Project**

* From the Looker dashboard, create a new Looker Project.
* Connect to the database that was configured in the previous section.
* Save the connection and verify that it has been successfully added to your project.

## **Troubleshooting**

If you encounter issues during the testing phase, consider reviewing all entered connection details for accuracy and ensure that the Looker instance can reach the database server over the network.

### **Authenticating to the Looker SQL Interface** <a href="#authenticating_to_the_looker_sql_interface" id="authenticating_to_the_looker_sql_interface"></a>

In Tellius, connection to Looker is established through a JDBC driver rather than direct API calls. For this authentication, users are required to enter the host, client ID, and client secret details.

#### **API keys**

This method involves using API keys as direct credentials. It may only be available during the preview of the SQL Interface.

{% hint style="info" %}
API keys method may not be available beyond the Beta Testing phase.
{% endhint %}

### **Generating API keys for Looker user**

* In Looker, click on **Users** under **Users** in the left pane. The list of user accounts will be displayed.
* Select the required Looker user and click on the **Edit Keys** button next to **API keys**.

<figure><img src="https://content.gitbook.com/content/z4Tm2IzKyAiWUWiskgq5/blobs/Qr6aHagTtY4oUzq9ANTa/image.png" alt="" width="563"><figcaption><p>Editing API keys</p></figcaption></figure>

* If the keys are already generated, then the client ID and client secret will be displayed. If you want to generate a new pair of keys, click on "**New API key**".

<figure><img src="https://content.gitbook.com/content/z4Tm2IzKyAiWUWiskgq5/blobs/1xUaKsanHh5nntxGTrmF/image.png" alt="" width="563"><figcaption><p>New API Keys</p></figcaption></figure>

* If there are no existing keys, then "*No API keys found*" will be displayed. Click on "**New API key**" to create new keys.

<figure><img src="https://content.gitbook.com/content/z4Tm2IzKyAiWUWiskgq5/blobs/3USmNTRlWh142iTbl8j1/image.png" alt="" width="254"><figcaption><p> Creating new API keys</p></figcaption></figure>

* Copy the **Client ID** and **Client Secret** as they will be required while connecting from Tellius.
* Use the client ID as your username and the client secret as your password.

{% hint style="info" %}
It's recommended to use dedicated user accounts for API scripts for better security and control.
{% endhint %}

### **Getting the Host URL**

* Navigate to **General → Settings → Host URL** to obtain the host URL.

<figure><img src="https://content.gitbook.com/content/z4Tm2IzKyAiWUWiskgq5/blobs/Hiw1DexbnqKOi5Oz1zl6/image.png" alt="" width="563"><figcaption><p>Getting the host URL</p></figcaption></figure>

* Copy the **Host URL** as it will be required while connecting from Tellius.

## **Connecting to Looker from Tellius** <a href="#connecting_to_looker_from_tellius" id="connecting_to_looker_from_tellius"></a>

1. From Tellius interface, navigate to **Data → Connect → Create new** and select **Looker**.
2. Enable **Use validated datasource connection details** if you've already established a connection and want to reuse the same details.
3. Choose the required **Datasource** from the list of already established connections.
4. Click on **Save and Browse Host**.
5. If you're connecting for the first time,
   1. Enter the **Looker URL, Client ID**, and **Client Secret** obtained from the Looker interface.
   2. Provide the name of the **Datasource** which needs to be loaded.
   3. Click on **Browse Host**.
6. The list of tables will be displayed under **Select a table** tab.
7. Select the required tables and click on the **→** button to move to the Selected box.
8. Using the search bar, you can easily search for table names. The number of selected tables will be displayed beneath the table list.
9. Click on **Import** to import the selected tables.

<figure><img src="https://content.gitbook.com/content/z4Tm2IzKyAiWUWiskgq5/blobs/ytPLVtaf9KIjhnmcehBY/image.png" alt="" width="563"><figcaption><p>Configuring Looker on Tellius</p></figcaption></figure>
