---
sidebar_position: 4
title: Superset & Preset
description: Build dashboards with Apache Superset or Preset connected to MotherDuck via the DuckDB SQLAlchemy driver.
---

import useBaseUrl from '@docusaurus/useBaseUrl';

[Apache Superset](https://superset.apache.org/) is a powerful, open-source data exploration and visualization platform designed to be intuitive and interactive. It allows data professionals to quickly integrate and analyze data from various sources, creating insightful dashboards and charts for better decision making.

[Preset](https://preset.io/) is a cloud-native, user-friendly platform built on Apache Superset. It offers enhanced capabilities and managed services to leverage the power of Superset without needing to handle installation and maintenance.

In this guide, we'll cover how you can use MotherDuck with either Superset or Preset.

## Superset

### Setup

The easy way to get started locally with Superset is to use their [docker-compose configurations.](https://superset.apache.org/docs/installation/installing-superset-using-docker-compose/)

### Adding a database connection to MotherDuck

To make it work with DuckDB & MotherDuck, you will have to install three extra Python packages in your local superset environment:
  - DuckDB SQLAlchemy driver [duckdb-engine](https://github.com/Mause/duckdb_engine)
  - DuckDB [duckdb](https://github.com/duckdb/duckdb)
  - Flask AppBuilder [flask_appbuilder](https://github.com/dpgaspar/Flask-AppBuilder)

1. First, you will have to clone the [Superset repository](https://github.com/apache/superset):

```bash
git clone https://github.com/apache/superset.git
```

2. Then create a new file in `superset/docker/requirements-local.txt` and add the following packages:

```text
duckdb-engine==0.17.0
duckdb==1.2.2
flask_appbuilder==4.6.3
```

3. Then build or run the docker container, depending whether this is the first time you run it or not, with the following command:

```bash
# First time running it
docker-compose up --build 

# Subsequent runs
docker-compose up
```

4. Once the container is running, you can access the Superset UI at [http://localhost:8088](http://localhost:8088) or at the address you specified in the `docker-compose.yml` file.

5. Once you are logged in, head over to "Settings" and click on "Database Connections"

<img
  src={useBaseUrl('/img/integrations/superset_1.png')}
  alt="Database Connections"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

6. Click on "+ Database"

<img
  src={useBaseUrl('/img/integrations/superset_2.png')}
  alt="Add Database"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

7. In the Dropdown, pick "MotherDuck"

<img
  src={useBaseUrl('/img/integrations/superset_3.png')}
  alt="Select MotherDuck"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

:::note
If MotherDuck isn't listed, there's probably an error in the installation of the `duckdb-engine`. Review the installation steps under (2) to install this extra python package.
:::

8. Enter the database name that you want to connect to and the MotherDuck token of the user or service account that you want to use to connect to MotherDuck

:::info
`Database name` is **optional**. Instead of specifying a database name, you can leave it empty to connect to all databases.
:::

<img
  src={useBaseUrl('/img/integrations/superset_4.png')}
  alt="MotherDuck Connection"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

9. Finally, you can test your token/connection is valid by clicking "Test connection" and click "Connect".

Now your MotherDuck database is available in Superset and you can start querying data and making some dashboards!

## Preset

### Setup

You can register a Preset account for [free](https://preset.io/pricing/) (up to 5 users).
Upon your account creation, you will need to create a workspace and be prompted to connect to your data source.

### Adding your first database connection to MotherDuck

When you first setup Preset, you will be offered to create a connection to a databse. Preset has a direct integration with MotherDuck, making the connection process simpler.

1. In the Database Connection Dropdown in "Connect your first database", select "MotherDuck" directly

<img
  src={useBaseUrl('/img/integrations/preset_1.png')}
  alt="MotherDuck Integration"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

2. Enter your MotherDuck credentials and database information

<img
  src={useBaseUrl('/img/integrations/preset_2.png')}
  alt="MotherDuck Credentials"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

3. Click "Connect" to verify your connection is valid.

:::note
The Database Name needs to be prefixed with `md:` to connect to MotherDuck.
The Access Token is the token you created in the [MotherDuck dashboard](https://app.motherduck.com).
:::

Now your MotherDuck database is available in Preset and you can start creating dashboards immediately!

:::info
You can connect to multiple databases using a single MotherDuck connection.
:::

### Adding additional database connections

When adding more database connections to Preset, you can choose the option of "Get MotherDuck token". This generates a new token from the MotherDuck account you are logged into.

1. Add a database connection by going to "Settings", then "Database Connections"

<img
  src={useBaseUrl('/img/integrations/preset_3.png')}
  alt="Settings Preset"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

2. In the Database Connections page, click on "+ Database" in the top right corner

<img
  src={useBaseUrl('/img/integrations/preset_4.png')}
  alt="Add Database"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

3. In the dropdown, select "MotherDuck" (see above)

4. Enter your MotherDuck credentials and database information
   1. Here you have the option to generate a new token using the `Get MotherDuck token` button or use a token you previously created.

<img
  src={useBaseUrl('/img/integrations/preset_5.png')}
  alt="MotherDuck Credentials"
  style={{ maxWidth: '400px', width: '100%', height: 'auto', margin: '1rem 0' }}
  loading="lazy"
/>

:::caution
Given that usually BI tools such as Preset and Superset are connected to service accounts, we do not recommend the "Get MotherDuck token" option for production systems but only for testing.
For production systems the recommended approach is to generate an access token for the dedicated service account using the MotherDuck REST API and connect this account to Preset instead.
:::
