📘 Introduction

Streamlit is a great tool for building small data apps in Python. DuckDB is a great local database for analytics. Together, they are a very practical combination when you want an interactive app that can read data, write new records, and update existing records without setting up a separate database server.

In this tutorial, you will build a simple task tracker. The app will store tasks in a local DuckDB database, show the current tasks in Streamlit, add new tasks through a form, and mark open tasks as done.

The example is intentionally small, but the pattern is useful for many beginner data apps: internal tools, lightweight dashboards, annotation apps, data quality review screens, and small operations trackers.

💡 What are we implementing?

We will build this local workflow:

Streamlit app -> DuckDB database -> tasks table

The app will do three important things:

  • read tasks from DuckDB
  • write new tasks to DuckDB
  • update task status in DuckDB

This means the app is not just a static dashboard. It can change the underlying database based on user interaction.

✅ Prerequisites

Before we start, you should have:

☑️ Python 3.9 or newer installed
☑️ Basic knowledge of running terminal commands
☑️ A text editor such as VS Code
☑️ No API key or cloud account required

⚙️1️⃣ Create a project folder

First, create a new folder for the project:

mkdir streamlit-duckdb-data-app
cd streamlit-duckdb-data-app

Create and activate a virtual environment:

python -m venv .venv
source .venv/bin/activate

On Windows, activate it with:

.venv\Scripts\activate

📦2️⃣ Install package

Install the Python packages we need:

pip install streamlit duckdb pandas

streamlit builds the app interface, duckdb stores and queries the local database, and pandas helps display query results as data frames.

🗃️3️⃣ Create the DuckDB database

Before we create the app, we will create a small DuckDB database with sample task data. Create a file named seed_database.py:

import duckdb


connection = duckdb.connect("tasks.duckdb")

connection.execute(
    """
    create or replace table tasks (
        id integer,
        title varchar,
        owner varchar,
        status varchar,
        created_at date,
        updated_at date
    )
    """
)

connection.execute(
    """
    insert into tasks values
        (1, 'Review customer data', 'Data Team', 'open', '2026-01-10', '2026-01-10'),
        (2, 'Create weekly dashboard', 'Analytics Team', 'open', '2026-01-11', '2026-01-11'),
        (3, 'Document DuckDB workflow', 'Data Team', 'done', '2026-01-12', '2026-01-12')
    """
)

connection.close()

print("Created tasks.duckdb with sample task data.")

Run the script:

python seed_database.py

You should see:

Created tasks.duckdb with sample task data.

At this point, you already have a local DuckDB database file named tasks.duckdb.

If you want to go deeper with practical data app examples, the Academy section continues with the full Streamlit app, database writes, status updates, validation queries, and troubleshooting notes.

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In