---
title: "Stop Waiting on the Warehouse: Query Marketing Exports Locally With DuckDB"
description: Most ad-hoc marketing questions do not need a warehouse load or a crashing spreadsheet. Here is how to query ad, CRM, and Search Console exports in place with DuckDB, and give your AI assistant a safe, read-only sandbox.
author: LETSGROW Dev Team
date: 2026-11-22
category: Analytics
tags: ["DuckDB", "SQL", "Marketing Analytics", "Data Tools", "Text-to-SQL"]
url: "https://letsgrow.dev/blog/duckdb-local-marketing-analytics-csv-exports"
---
Most marketing analysis questions do not need a data warehouse. They need someone to join last month's ad platform export to a CRM export and a Search Console download, and get an answer before the meeting starts. Teams handle this in one of two bad ways: they fight a spreadsheet that chokes at 200,000 rows, or they file a ticket to load the files into BigQuery and wait three days. Both are wrong. For the large middle ground of ad-hoc marketing analysis, the right tool is DuckDB, an in-process analytical database that runs on a laptop, reads your files where they sit, and answers SQL in seconds.

This is not a "replace your warehouse" argument. Your warehouse stays the source of truth for governed, recurring reporting. DuckDB is for everything that happens before a question earns a pipeline.

## Why the Spreadsheet-or-Warehouse Choice Is a False One

Spreadsheets fail on volume and on joins. A year of daily campaign data across four ad platforms plus a lead export is easily a few million rows. VLOOKUP across that is slow, fragile, and impossible to audit later.

Warehouses fail on latency of a different kind. The query runs fast, but getting the data there does not. Someone has to define a schema, set up a load job, grant access, and decide where the table lives. For a one-off question about whether a creative refresh moved cost per lead, that overhead kills the analysis before it starts.

DuckDB sits in the gap. It is a single binary or a pip install, with no server to run and no credentials to manage. It is columnar and vectorized, so aggregations over millions of rows finish in well under a second on ordinary hardware. And it treats files as tables, which is the feature that matters most for marketing work.

::compare-table
title: "Where Each Tool Fits in Marketing Analysis"
columns: ["Tool", "Setup Time", "Comfortable Data Size", "Best For"]
rows:
  - ["Spreadsheet", "None", "Under ~100k rows", "Quick looks and shared editing"]
  - ["DuckDB on a laptop", "Minutes", "Millions to low billions of rows", "Ad-hoc joins across exports, prototyping metrics"]
  - ["Cloud warehouse", "Days to weeks", "Effectively unlimited", "Governed, recurring, multi-user reporting"]
::

## Query Your Exports Where They Sit

The workflow is simple: dump every export into one folder and query it directly. No import step.

```sql
-- Every monthly Google Ads export in one table, with the source file tracked
SELECT *
FROM read_csv('exports/google_ads/*.csv', union_by_name = true, filename = true);
```

The glob pattern reads every file at once. `union_by_name` handles the classic problem where a platform added a column in March, and `filename` keeps track of which export each row came from, so you can audit odd numbers later.

From there, joins work like any SQL database. Blend spend from two ad platforms with closed-won deals from a CRM export:

```sql
WITH spend AS (
  SELECT campaign, date_trunc('month', day) AS month, sum(cost) AS cost
  FROM read_csv('exports/*/spend_*.csv', union_by_name = true)
  GROUP BY ALL
),
deals AS (
  SELECT utm_campaign AS campaign, date_trunc('month', close_date) AS month,
         count(*) AS won, sum(amount) AS revenue
  FROM read_csv('exports/crm/deals.csv')
  WHERE stage = 'Closed Won'
  GROUP BY ALL
)
SELECT s.campaign, s.month, s.cost, d.won, d.revenue,
       round(s.cost / nullif(d.won, 0), 2) AS cost_per_win
FROM spend s LEFT JOIN deals d USING (campaign, month)
ORDER BY s.month, s.cost DESC;
```

Three habits make this repeatable. First, run `SUMMARIZE` on every new export before trusting it. It returns min, max, null percentage, and approximate distinct counts per column, which catches broken UTMs and empty date fields immediately. Second, convert cleaned data to Parquet with `COPY (...) TO 'clean/ads.parquet' (FORMAT parquet)`. Parquet files are a fraction of the CSV size and query much faster. Third, save your queries as `.sql` files in a Git repo. A query in version control is an analysis someone can rerun next quarter. A spreadsheet tab is not.

DuckDB also reads beyond local CSVs. Extensions let it query Parquet in S3 or Google Cloud Storage, read Excel files, and attach a live Postgres or MySQL database as if it were a local schema. That means you can join a production database snapshot to a CSV export in one query without moving either.

## Give Your AI Assistant a Sandbox, Not Warehouse Credentials

This is where DuckDB becomes an AI tool, not just an analytics tool. Text-to-SQL with an LLM is now good enough to be useful for marketing questions, but pointing an assistant at your production warehouse raises real problems: query costs, accidental full-table scans, and access to data the question never needed.

DuckDB flips the risk model. Give the model a local database file containing only the exports relevant to the question. The blast radius of a bad query is your laptop, the cost is zero, and the data the model can touch is exactly the data you chose.

A practical setup looks like this:

1. **Build a scoped database.** Load the relevant cleaned Parquet files into a single `.duckdb` file for the analysis.
2. **Open it read-only.** Connect with read-only access so generated SQL cannot modify or drop anything.
3. **Pass the schema, not the data.** Give the model the output of `DESCRIBE` for each table plus a few sample rows and a short glossary ("`cost` is in USD, `day` is the platform's reporting date in account timezone").
4. **Require the SQL in the answer.** Every number the assistant reports should come with the query that produced it, so a human can check the logic before the number goes in a slide.

Most coding assistants and many desktop AI apps can already run local commands or connect to MCP servers, and community DuckDB MCP servers exist. Whatever the wiring, the principles hold: scoped data, read-only access, and visible SQL.

## Know When to Graduate a Query

DuckDB is a workbench, and workbench output should not quietly become the company's official numbers. Use a simple promotion rule: if a query gets run on a schedule, feeds a dashboard other people rely on, or defines a metric that appears in board materials, it moves to the warehouse with proper modeling, tests, and ownership.

The good news is that the move is cheap. DuckDB's SQL dialect is close to Postgres, the Parquet files you produced load straight into any major warehouse, and the logic is already written and validated. You are not prototyping in a toy and rebuilding from scratch. You are promoting tested SQL.

::checklist
title: "Local Marketing Analytics Setup With DuckDB"
items:
  - "Install DuckDB via the CLI or pip and create one project folder per analysis"
  - "Drop raw exports into an exports/ folder organized by source"
  - "Query exports in place with read_csv and glob patterns, using union_by_name and filename"
  - "Run SUMMARIZE on every new export before using it"
  - "Write cleaned tables to Parquet for speed and smaller files"
  - "Keep every query in a .sql file under version control"
  - "Give AI assistants a scoped, read-only DuckDB file and require the SQL with every answer"
  - "Promote any query that runs on a schedule or feeds a shared dashboard to the warehouse"
::

The fastest marketing teams are not the ones with the biggest warehouse. They are the ones who can answer a cross-platform question in ten minutes with a laptop, prove the answer with a query, and only build pipelines for the questions that keep coming back.
