# connection

<br />

## Usage

```
connection: "connection_name"
```

|---|---|
| Hierarchy [Model File](https://docs.cloud.google.com/looker/docs/reference/param-model) `connection` | Default Value None <br /> Accepts A string containing the name of a connection |

## Definition

`connection` specifies the database connection from which a model will retrieve data. Database connections are defined and named on the [**Connections**](https://docs.cloud.google.com/looker/docs/admin-panel-database-connections) page in the **Database** section of Looker's **Admin** panel.

> [!IMPORTANT]
> **Important:** Each model can specify only one connection. If you want to use multiple database connections in a project, you must create a different model file for each connection.

When a Looker developer defines a connection in a model file using the `connection` parameter, the [Looker IDE](https://docs.cloud.google.com/looker/docs/looker-ide) displays a drop-down that suggests database connections that are available on the instance.

## Example

In the `ecommerce.model.lookml` file, specify that the model should retrieve data from the `ecommerce_events` connection:

    connection: "ecommerce_events"

## Common challenges

### `connection` must reference a connection name from Looker's admin settings

The connection name that is referenced by `connection` does not take the name of an actual database or schema. The name must be one of the connections that is available when you're [configuring a model](https://docs.cloud.google.com/looker/docs/manage-projects#adding_and_editing_configurations) or on the [**Connections**](https://docs.cloud.google.com/looker/docs/admin-panel-database-connections) page in Looker's **Admin** panel.

### If a model configuration exists, then `connection` can only reference an allowed connection

If a Looker developer specifies a connection in the model file that is not allowed in the model configuration, then any query on that model will not run.

### If a model configuration does not exist, then only certain people can query

If you have not been given the [`manage_models` permission](https://docs.cloud.google.com/looker/docs/admin-panel-users-roles#permissions_list) (which is included in the admin role) then the model must be configured before you can run queries on the model.