Data Visualisation Tools With DuckDB & MotherDuck - Hex/Preset

2023/09/05Featuring:

TL;DR: This guide walks you through connecting your MotherDuck data to two popular visualization tools: Hex and Apache Superset. Learn how to create and share live dashboards, moving from local data analysis to collaborative reporting.

DuckDB has changed how we handle local data processing. You can build powerful data pipelines right on your laptop. But once you've wrangled your data and found those initial insights, you hit a wall: how do you share your work?

A local DuckDB database isn't easily accessible to the BI tools your team uses for dashboards and reporting.

Good visualizations turn raw numbers into insights. Well-crafted charts and dashboards help teams spot trends, identify outliers, and make better decisions. When you bridge the gap between local analysis and shared visualizations, your entire organization can engage with the data.

We built MotherDuck to solve this problem. As a serverless analytics platform based on DuckDB, MotherDuck makes your data available to a whole ecosystem of visualization tools without the friction of setting up complex infrastructure.

This guide covers two practical examples of connecting MotherDuck to popular visualization platforms. We won't benchmark which tool is "best." Instead, we'll help you pick the right one for your needs:

  1. Hex: A collaborative, notebook-style platform for data science and analytics.
  2. Apache Superset (via Preset): An open-source BI tool for building interactive dashboards.

We'll assume you already have your data loaded into MotherDuck. If not, check our data loading documentation.

A Note on Security and Best Practices

Before connecting any third-party application to your data, follow security best practices. When connecting to MotherDuck, always use a service token and grant it only the permissions it needs.

Never hardcode your credentials or tokens directly in your code. Use the built-in secret management features that tools like Hex and Preset provide to store your tokens securely. This prevents accidental exposure and makes managing access much easier.

Option 1: Fast, Collaborative Visuals with Hex

Hex is a "super notebook." It combines the flexibility of Python and SQL with no-code elements, making it an ideal environment for collaborative data science. You can move quickly from exploration to a polished, shareable report or application.

Let's connect MotherDuck to Hex and build a simple chart.

Step-by-Step Guide to Connecting Hex

DuckDB comes pre-installed in the Hex environment. This means connecting to MotherDuck takes just a few steps.

Check Your DuckDB Version

MotherDuck requires a recent version of DuckDB to function correctly. Verify the version in your Hex notebook by running a simple Python cell.

Copy code

# Check the installed DuckDB version in the Hex environment import duckdb print(duckdb.__version__)

You can always find the currently supported DuckDB version in our documentation. As of this writing, you're good to go!

Securely Store Your MotherDuck Token

Never hardcode credentials. Hex has a built-in secret manager that makes this easy.

  1. Navigate to the "Secrets" tab in the left-hand sidebar of your Hex project.
  2. Click "Add secret" and create a new secret named motherduck_token.
  3. Paste your MotherDuck service token into the value field. You can generate a token from your MotherDuck profile page.

Hex will now make this secret available as a Python variable within your notebook.

Connect to MotherDuck

With your token securely stored, connecting is simple. Use a Python cell to load the secret as an environment variable. The DuckDB client will automatically detect it for authentication.

Copy code

import os import duckdb # Hex injects the secret as a Python variable named after the secret os.environ['MOTHERDUCK_TOKEN'] = motherduck_token # Connect to MotherDuck using the 'md:' prefix # The client automatically uses the MOTHERDUCK_TOKEN environment variable con = duckdb.connect(database='md:')

The md: connection string tells the DuckDB client to connect to your MotherDuck account instead of a local file.

Run a Query and Create a Visualization

Now for the fun part. We'll query the sample_data database, which is a shared database available to all MotherDuck users. It's filled with useful datasets like the NYC Taxi data.

We'll find the peak taxi pickup hours throughout the week.

In a new Python cell, run this SQL query and load the results into a pandas DataFrame.

Copy code

# Query the NYC taxi dataset to find peak hours peak_hours_df = con.sql(""" SELECT dayname(tpep_pickup_datetime) AS day_of_week, strftime('%H', tpep_pickup_datetime) AS hour_of_day, COUNT(*) AS trip_count FROM sample_data.nyc.taxi GROUP BY day_of_week, hour_of_day ORDER BY day_of_week, hour_of_day; """).to_df() # Display the DataFrame peak_hours_df

With your peak_hours_df DataFrame ready, add a "Chart" cell in Hex. Configure it as a bar chart with hour_of_day on the X-axis, trip_count on the Y-axis, and use day_of_week to group the data.

In just a few clicks, you have a visualization showing taxi trip patterns across the week.

Hex excels at notebook-style analysis. But if you need a more traditional BI dashboard, Apache Superset is your answer.

Option 2: Building Dashboards with Superset and Preset

For traditional business intelligence dashboards, Apache Superset is a fantastic open-source choice. Created by Maxime Beauchemin (who also created Airflow), Superset is a powerful platform for data exploration and visualization.

For this demo, we'll use Preset, a fully managed cloud service for Superset. This lets us skip the setup and dive right into connecting our data.

The process is nearly identical if you're self-hosting Superset, though you'll need to install the database driver manually. Preset is particularly great for users who prefer a UI-driven workflow, following a logical path: SQL Lab -> Chart -> Dashboard.

Step-by-Step Guide to Connecting Preset

Add a New Database Connection

In your Preset workspace, navigate to Settings in the top-right menu and select Database Connections. Click the + Database button to add a new source.

Configure the MotherDuck Connection

From the list of supported databases, select MotherDuck. Preset presents a simple form for your connection details.

  • Display Name: Give your connection a memorable name, like "My MotherDuck."
  • Database Name (Optional): You can specify a single database to connect to (e.g., md:my_db). However, you can leave this field blank to query across all databases your token can access with a single connection.
  • Access Token: Paste your MotherDuck service token here.

Test and Connect

Click the Test Connection button to verify your credentials. If you see a "Connection looks good!" message, click Connect to save the data source.

Build a Dashboard

With MotherDuck connected, you can follow Preset's intuitive workflow:

  1. Explore in SQL Lab: Go to the SQL Lab and write the same query we used in Hex to find the peak NYC taxi hours. Run the query to see the results.
  2. Create a Dataset: From the query results, click Save dataset to make your query's output a reusable data source for charts.
  3. Build a Chart: Create a new chart, selecting your newly saved dataset. Configure it as a bar chart just as you did in Hex.
  4. Add to Dashboard: Save the chart and add it to a new or existing dashboard. You can now resize the chart, add other visualizations, and share the dashboard with your team.

Choose Your Path to Visualization

Two distinct, powerful ways to bring your MotherDuck data to life:

  • Hex is your go-to for iterative, code-first analysis and quickly publishing data apps and reports from a notebook interface.
  • Preset and Superset provide a robust, UI-driven BI experience for building and sharing more structured, interactive dashboards.

MotherDuck doesn't lock you into a single tool. It acts as the central, serverless bridge between your data and the entire analytics ecosystem.

Now it's your turn. Connect your own data and start building. For more detailed guides, check out our official documentation for Hex and Superset/Preset.

Is there a specific data visualization tool you'd like us to cover next? Let us know.

Happy dashboarding

Frequently Asked Questions (FAQs)

What is MotherDuck?

MotherDuck is a serverless analytics platform based on DuckDB that allows you to easily connect your local data to a variety of business intelligence and data visualization tools.

Can I use other visualization tools with MotherDuck?

Yes, MotherDuck works with a wide ecosystem of analytics and BI tools. This guide focuses on Hex and Superset, but you can connect to many others.

Do I need a MotherDuck account to follow this tutorial?

Yes, you'll need a MotherDuck account and your service token to connect to Hex and Superset.

0:00dark DB has been all around for storing reading data and data pipelines but what's possible in the dashboarding world indeed once you have your data somewhere you easily have a bi tool that would query this data the challenge here is that you have a local doc DB with your data and it's not so easy to share and make it available for you database

0:21Edition and that's where mother duck comes into play right yeah that's what I was about to say if you have data in mother deck which is a serverless analytics platform based on techdb you can use a couple of databization tools we won't cover how to load data to mother duck but it's pretty straightforward coming from docdb or

0:42some parquet CSV file and I'll put a link in the description in case you need to do so alright coming back to database we'll cover two options here x and superset preset yeah I know it's three options I still can count this video is not the Benchmark of which the AWS tool is the best but I would tell you one

1:04great feature I like about each one so let's hit some database I promise there won't be any icon X is a software for collaborative data science and analytics using python SQL and no code you can see it as a super notebook it provides different kind of cells including database cells and you can easily publish and share it through your

1:27teammates or external people and that's my favorite feature because you can go from exploration to publishing really fast it doesn't matter how great your Insight is if you cannot share it right so guess what time to be in X is already pre-installed and anywhere you have 30b you can run mother deck it's worth to note that mother deck at this point of

1:50time only supports one version of WB the latest you can always check which version we are supporting in our docs you can quickly run a cell in a in Python to double check this version yes we are good to go the first step is to safely store your murder DAC token XL is a feature for this you can do this by

2:11creating a new Secret in X to get your model black service token just head up over your profile and you will see right there the secret will be available as a python variable and you can export it then as an environment variable for our session would it be a sequel or a python cell and that's pretty much it now you

2:31can connect as you would do through a python for instance we just need to mention MD colon and that's because our service token is already available as an environment variable so let's run a query against the sample data database this is a share database which is available for all mother deck users and contains a bunch of data set that you

2:53can play with let's run a query against the New York City Taxi data set to understand what are the big hours now we have this query returned as a data frame and we can add a short cell select our data frame and the right parameters to have this beautiful bar chart to understand all the peak hours is evolving over the week okay

3:16dashboarding might not be the place where I excel and neither Excel alright let's move to the next database to preset and superset so Apache superset is an open source data exploration and visualization platform designed to be intuitive and interactive The Mastermind behind this projects is Maxim boshima who also created airflow while my open source project seems to fizzle out it

3:43keeps doing home run so superset can quickly integrate and analyze data from various sources including dagdb and modern deck for the sake of this demo we're gonna use preset but rest assure it's almost the same thing if you need to connect mother duck with superset and I'll put the link in the description for both guide in case you need so preset is

4:03great for people with less coding skills the dashboarding experience is easy through DUI and I really like how they started with the SQL lab then you create a chart then you create a dashboard and you have reusable component towards tools so let's connect to preset head over to settings and click on database connection select mother deck and we are going to need to fill the SQL

4:28Alchemy ERI that followed this pattern

4:32note that the date of database name is optional so you can have one connection to Mother deck and query multiple databases finally you can test that your token connection is valid by clicking test connection and click connect all right let's make the same bar chart we just had earlier in X first we can go to the SQL app run the query and save it as

4:54a data set next we create the same bar shot we did earlier

5:01and once it's done we can add this one to a dashboard and then I can put it anywhere resize it it's beautiful yes you should be proud of your art even if it's modest look at what my kit did it's beautiful yes no I'm not biased all right here you have two options to do amazing databizations using X or superset slash preset and

5:27don't worry more are coming don't forget to check the description for written tutorials and content about these tools and do let me know if there is a specific database tool that you like me to cover anyway quite you soon and keep on coding foreign

FAQS

How do you connect Hex to MotherDuck for data visualization?

To connect Hex to MotherDuck, first store your MotherDuck service token as a Hex Secret for secure access. Then export the token as an environment variable in your session. After that, connect using the standard DuckDB Python connection with md: as the connection string, since your service token is already available as an environment variable. From there, you can run SQL queries against MotherDuck's sample data databases and use Hex's chart cells to create visualizations from the resulting data frames.

How do you set up Apache Superset or Preset with MotherDuck?

To connect Preset (or Apache Superset) to MotherDuck, navigate to Settings, then Database Connections, and select MotherDuck. Fill in the SQLAlchemy URI following the required pattern with your MotherDuck token. The database name is optional, so a single connection can query multiple databases. After testing the connection, you can use SQL Lab to run queries, save results as datasets, create charts from those datasets, and assemble them into dashboards using the drag-and-drop UI.

What data visualization tools work with DuckDB and MotherDuck?

Several visualization tools work well with DuckDB and MotherDuck. Hex is a collaborative data science platform that works as a notebook with Python, SQL, and no-code cells. Its strength is going from exploration to publishing quickly. Apache Superset (and its hosted version Preset) is an open-source visualization platform that works well for users with less coding experience, offering a UI-driven dashboarding workflow. Both tools can connect directly to MotherDuck to query data stored in the cloud.

Related Videos

" Preparing Your Data Warehouse for AI: Let Your Agents Cook" video thumbnail

2026-01-27

Preparing Your Data Warehouse for AI: Let Your Agents Cook

Jacob and Jerel from MotherDuck showcase practical ways to optimize your data warehouse for AI-powered SQL generation. Through rigorous testing with the Bird benchmark, they demonstrate that text-to-SQL accuracy can jump from 30% to 74% by enriching your database with the right metadata.

AI, ML and LLMs

SQL

MotherDuck Features

Stream

Tutorial

"No More Writing SQL for Quick Analysis" video thumbnail

0:09:18

2026-01-21

No More Writing SQL for Quick Analysis

Learn how to use the MotherDuck MCP server with Claude to analyze data using natural language—no SQL required. This text-to-SQL tutorial shows how AI data analysis works with the Model Context Protocol (MCP), letting you query databases, Parquet files on S3, and even public APIs just by asking questions in plain English.

YouTube

Tutorial

AI, ML and LLMs

"The MCP Sessions - Vol 2: Supply Chain Analytics" video thumbnail

2026-01-21

The MCP Sessions - Vol 2: Supply Chain Analytics

Jacob and Alex from MotherDuck query data using the MotherDuck MCP. Watch as they analyze 180,000 rows of shipment data through conversational AI, uncovering late delivery patterns, profitability insights, and operational trends with no SQL required!

Stream

AI, ML and LLMs

MotherDuck Features

SQL

BI & Visualization

Tutorial