# Database connections

> Configure Superset database connectivity.

Superset requires a metadata database for storing slices, connections, tables, dashboards and other metadata. The actual connection string is calculated by the operator so that the user does not need to remember the exact structure. Using async queries with celery workers also requires a broker and a results backend.

## Metadata database

### PostgreSQL

```yaml
spec:
  clusterConfig:
    metadataDatabase:
      postgresql: (1)
        host: superset-postgresql
        database: superset
        credentialsSecretName: superset-postgresql-credentials (2)
```

(1) A reference to one of the supported database backends (e.g. `postgresql`).
(2) A reference to a Secret which must contain the two keys `username` and `password`.

### Generic connections

Alternatively, these connections can also be defined in full in a referenced Secret:

```yaml
spec:
  clusterConfig:
    metadataDatabase:
      generic:
        connectionUrlSecretName: superset-metadata (1)
```

(1) A reference to a Secret which must contain the single key `connectionUrl` e.g. `postgresql://superset:superset@superset-postgresql/superset`

## Broker

The broker queue is required to schedule or pass queries on the celery workers.

### Redis

A redis broker can be configured in the `clusterConfig`:

```yaml
spec:
  clusterConfig:
    celeryBroker:
      redis:
        host: redis-master
        port: 6379
        credentialsSecretName: superset-redis-credentials
```

### Generic connections

Alternatively, these connections can also be defined in full in a referenced Secret:

```yaml
spec:
  clusterConfig:
    celeryBroker:
      generic:
        connectionUrlSecretName: superset-redis-broker-url (1)
```

(1) A reference to a Secret which must contain the single key `connectionUrl` e.g. `redis://:redis@redis-master/0`

## Results Backend

Celery workers store their results in the configured results backend.

### Redis

A redis broker can be configured in the `clusterConfig`:

```yaml
spec:
  clusterConfig:
    celeryResultsBackend:
      redis:
        host: redis-master
        port: 6379
        credentialsSecretName: superset-redis-credentials
```

### S3

Currently not supported.

### Generic connections

Alternatively, these connections can also be defined in full in a referenced Secret:

```yaml
spec:
  clusterConfig:
    celeryResultsBackend:
      generic:
        connectionUrlSecretName: superset-redis-results-backend-url (1)
```

(1) A reference to a Secret which must contain the single key `connectionUrl` e.g. `redis://:redis@redis-master/0`
