Data Visualisation Tools With DuckDB & MotherDuck - Hex/Preset
2023/09/05TL;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:
- Hex: A collaborative, notebook-style platform for data science and analytics.
- 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.
- Navigate to the "Secrets" tab in the left-hand sidebar of your Hex project.
- Click "Add secret" and create a new secret named
motherduck_token. - 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:
- 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.
- Create a Dataset: From the query results, click Save dataset to make your query's output a reusable data source for charts.
- Build a Chart: Create a new chart, selecting your newly saved dataset. Configure it as a bar chart just as you did in Hex.
- 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.
Related Videos

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
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
2026-01-13
The MCP Sessions Vol. 1: Sports Analytics
Watch us dive into NFL playoff odds and PGA Tour stats using using MotherDuck's MCP server with Claude. See how to analyze data, build visualizations, and iterate on insights in real-time using natural language queries and DuckDB.
AI, ML and LLMs
SQL
MotherDuck Features
Tutorial
BI & Visualization
Ecosystem

