Verify Datasette Charts Against the SQL Behind Them

Verify Datasette charts with an independent SQLite query, switch the package filter in the chart builder, and check that chat describes the chart you can see.

Datasette charts reconciliation ledger with the same day and sum settings for two packages and different values on November 16 and 17.Datasette charts reconciliation ledger with the same day and sum settings for two packages and different values on November 16 and 17.
Illustrative SQLite fixture. Switching the package filter changes the two daily totals. Check each date and value with independent SQL. Filter behavior from the Datasette Charts documentation.

A teammate asks for a chart of daily downloads. You get an upward line in chat, then switch the package in the chart builder and see a downward line. The conversation still contains the first chart. Before sharing the second, you need to know which package the chart is using, which SQL rows account for its points, and which view the agent is describing. This tutorial uses Datasette charts to check all three with four rows of SQLite data.

You’ll verify the two daily points for sqlite-utils, change the package filter, verify the two daily points for datasette, and recover the original view from its link. The fixture and expected observations are illustrative. Simon Willison documented the chat-to-builder handoff and asked a follow-up after switching packages on November 24, 2026. The release notes identify that integration as a prerelease feature in datasette-charts 0.2a0. His demonstration shows the interaction. The four rows below give you values you can independently calculate and check on your own instance. Willison’s demonstration · 0.2a0 release notes

Load four rows with known totals

  1. Use a training instance or sandbox where you can make a fixture database available. You need compatible Datasette, datasette-charts and datasette-agent in the same environment, plus a configured model authorized to call tools. The charts repository documents a Datasette build newer than 1.0a43, at commit 56e02c1 or later. The analyst account needs datasette-agent for chat, view-table for table charting, and execute-sql on the fixture database for the independent query and compiled chart SQL. You can run the browser exercise with a read-only analyst account after the fixture is loaded. Charts requirements and permissions · Agent model selection and permissions

  2. Open a new disposable SQLite database in a writable SQLite client. Run the following script there. If someone else manages the training instance, have that person run the script in a scratch database and make the file available to Datasette. Use the custom SQL editor in the browser later for the read-only checks. Datasette SQL editor documentation

    CREATE TABLE stats (
        package TEXT NOT NULL,
        day TEXT NOT NULL,
        downloads INTEGER NOT NULL,
        PRIMARY KEY (package, day)
    );
    
    INSERT INTO stats (package, day, downloads) VALUES
        ('sqlite-utils', '2026-11-16', 12),
        ('sqlite-utils', '2026-11-17', 18),
        ('datasette', '2026-11-16', 30),
        ('datasette', '2026-11-17', 9);
    

    The composite primary key captures the unit of observation. Each package can have a row on each day, and the same package and day together can occur only once. The explicit NOT NULL declarations require both key fields and a download value. The INSERT names its columns so you can see where the two strings and the integer go. The day values are ISO calendar dates, with no time of day to reconcile. The charts plugin documents detection of ISO dates from values. SQLite CREATE TABLE · SQLite INSERT · Charts date detection

  3. Open the fixture database’s index in Datasette. Select stats and clear any existing filters. Look for both package names, both dates and four rows. If your instance has another table called stats, note the fixture database’s name now. Chat autocomplete can offer tables from more than one source, and a chart can look plausible even when it starts from the wrong table.

If the script reports that stats already exists, use a new scratch database. An existing table could have a different schema or additional rows. If the index has no stats table, confirm that the writable client saved to the database file served by the training instance. If the table does appear but shows fewer than four rows, clear the table filters before trying to load the fixture again. The unfiltered table gives you a direct check for a setup problem before you ask the model to find the data.

Ask for a chart and open its builder

  1. Start a conversation at /-/agent on the same instance. Type #stats in the chat input and select the fixture table from autocomplete with Enter or Tab. Look for the table pill above the composer. If pasting the text below leaves #stats as plain text, replace that portion using autocomplete before sending. Datasette Agent attaches details about the tagged table for the model, subject to the current actor’s permissions. Datasette Agent table references

    Use #stats to draw a line chart of daily total downloads for sqlite-utils.
    Use the stats table as the chart source and apply a table filter where package equals sqlite-utils.
    Put calendar dates from day on the x-axis, one point per date, and sum downloads on the y-axis.
    Use one series, with no split by package. Return an inline chart I can open in the chart builder.
    

    Asking for a table source gives you a chart attached to a table page. You can change the table filter later and see the same selected chart drawn over the filtered rows. The prompt defines what each point should mean. The chart tool accepts a source and a chart specification, and the plugin generates SQL to produce the plotted rows. If the agent builds from a custom query, the query itself expresses the row selection. Ask for the table path so you can test the table’s package filter directly. Datasette Charts agent tools and filtered sources

  2. In the inline chart, select Open in the chart builder. Inspect the panel’s database and table first. If the agent opened a SQL query page, ask it to regenerate using the stats table with a table filter. If the panel is on the right table without the intended filter, set the table’s package filter to equality with sqlite-utils and apply it. On narrow screens, use the Chat | Panel switch to reach the builder. Datasette Agent panel

  3. Inspect the builder for a line chart using day on the horizontal axis and one series, with downloads as the measure. Pick the finest date bucket the builder offers, and select a sum of downloads if the builder offers that aggregation. The README documents time-unit and aggregate controls without enumerating the day and sum choices. If you cannot find a day option or confirm the aggregation in the controls, use This chart’s SQL to check the grouping and measure directly. Proceed with the daily chart only once you can establish one plotted total per calendar date and confirm that the chart sums downloads. A title can survive a filter or settings change, so use the current filter and the generated query to establish what the chart represents. Charts builder controls and compiled SQL

Simon Willison’s Weblog page for the datasette-charts 0.2a0 release.
Simon Willison’s Weblog, November 24, 2026. The release post introduces the Datasette Agent integration and hosts Willison’s demonstration. · Original source

If chat opens without an available model, check the instance’s authorized tool-capable model choices with its administrator. If the model produces only prose or a table, try Suggested charts or Charts on the stats page. The plugin’s Build a chart path lets you assemble the same line manually and continue the numerical check. Record which path you used. A manually built chart can pass the SQL comparison. Completing the handoff exercise also requires an inline chart with its builder link in the conversation. Agent model selection · Manual chart builder

Reconcile the first chart with your own SQL

  1. Keep the builder in the conversation panel. In a separate browser tab, open the SQL editor from the fixture database index and paste the query below. When the editor presents the generated package parameter field, enter sqlite-utils and submit. This tab is where you calculate the expected points. Leaving the chart in the conversation panel preserves the page you want the agent to describe later. Datasette named SQL parameters

    SELECT day, SUM(downloads) AS daily_downloads
    FROM stats
    WHERE package = :package
    GROUP BY day
    ORDER BY day ASC;
    

    The package predicate makes the query independent of the active chart filter. GROUP BY day uses the stored calendar dates as the grouping key. SUM(downloads) adds the stored amounts, and ORDER BY day ASC gives you the points in the order you’ll read them along the horizontal axis. Each group in the fixture contains a single row. COUNT(*) would return one per day for a correctly filtered package because it measures the rows that contributed to each group. SQLite aggregate functions and SELECT syntax

  2. Read both rows of the independent result. November 16 should have daily_downloads of 12 and November 17 should have 18. Back in the builder, open This chart’s SQL and compare the compiled query and its result with the independent query. Look at the package restriction, the expression or column used for date grouping, and the aggregate applied to downloads. The generated SQL may express the grouping differently or give its output columns different names. Match both calendar dates and totals, then confirm the chart plots those points. Return to the chart if the SQL page has taken its place in the panel. Compiled chart SQL

  3. Copy the full URL of the verified chart page before changing the filter. If the address bar shows the conversation URL, open the fixture table in a standalone Datasette tab, apply the same filter, and select or rebuild the verified chart there before copying the address. Keep the query string that identifies the filtered table rows and the fragment that holds the selected chart. A link that omits the query string can reopen the same chart design over a different set of rows. Chart URL fragments and table filters

Both points matter. The two-day sum for sqlite-utils is 30, a number that also occurs as a single daily value for datasette. A summary that mentions 30 without a package and a date could be describing either result. Likewise, two points on the right dates only establish that the chart found two days. Matching each date to its value catches a chart using the wrong package or measure. The same principle applies when checking a bounded dashboard query against an existing visualization. Grafana MCP dashboard verification

Because the fixture has one row per package per day, several aggregates, including a sum and an average, could yield the same two values. A match proves which points the chart returned for these inputs. Check the aggregate separately in the compiled SQL to establish that it would still add the amounts if a source had several rows on the same date. This distinction matters when a small training example becomes the basis for a report on a larger table. SQLite aggregate functions

Switch packages and test the chat answer

  1. In the table page inside the chat panel, replace package = sqlite-utils with package = datasette. Apply the filter and check the table rows. They should now show only datasette. The plugin keeps a selected chart open when filtering a table and draws it from the filtered rows. Keep the date grouping and summed measure you verified on the first chart. This exercise changes one input so that any difference in the expected totals follows from which package’s rows are selected. Filtered table charts

  2. In the independent SQL tab, change the package parameter to datasette and run the same query again. Expect 30 on November 16 and 9 on November 17. Open This chart’s SQL for the updated view and compare both pairs with the independent result. Check the date grouping and the sum as you did for the first view. Return to the updated chart in the conversation panel after inspecting the generated SQL.

  3. With the verified datasette chart visible in the panel, send the follow-up below. The integration tells the agent the panel page address when you send a message after changing the chart. Leave the package name and values out of the question. If you include them, a reply could repeat the supplied details without demonstrating which view it used. Panel address and the chart integration

    Describe the chart currently open in the panel. Identify its package filter and list each date with its daily total downloads. Say whether the series rises or falls. If you cannot determine the current filter or values from the panel, say what you cannot verify.
    

Illustrative chart with two markers per package. sqlite-utils rises from 12 to 18 and datasette falls from 30 to 9.Illustrative chart with two markers per package. sqlite-utils rises from 12 to 18 and datasette falls from 30 to 9.
Illustrative daily downloads from the four-row SQLite fixture, November 16–17, 2026. The overlay compares the values expected from two separately filtered views.

These are illustrative expected observations for task:downloads-chart-01. The SQL results follow from the fixture. Judge the chat answer by its package, dates, totals and direction. A reply that says downloads fell but quotes the wrong dates or totals is still a mismatch. If the agent says it cannot determine the current view, record that as an unresolved chat check and use the chart and SQL rows for the numerical result.

Input Action Expected result
task:downloads-chart-01 with stats, package = sqlite-utils, one point per date and summed downloads Send the chart prompt, select Open in the chart builder, and compare This chart’s SQL with the independent SELECT using sqlite-utils in the package field. November 16 returns 12 and November 17 returns 18. The plotted line rises.
task:downloads-chart-01 with the same chart settings and package = datasette Replace the table’s package filter, run the independent SELECT with datasette in the package field, and compare both rows with the chart SQL. November 16 returns 30 and November 17 returns 9. The plotted line falls.
task:downloads-chart-01 with the verified datasette chart visible in the conversation panel Send the follow-up prompt without spelling out the new package or the expected values. An acceptable answer names datasette, says 30 then 9 on the corresponding dates, and describes a fall. An answer giving 12 then 18 describes the earlier series.
task:downloads-chart-01 with the original filtered chart URL copied before the switch Reopen the saved URL and compare the reopened chart with the independent query using sqlite-utils again. The table shows the sqlite-utils filter and the points return to 12 and 18 in date order.

Locate a mismatch before changing the chart

Decision tree comparing chart and independent SQL, then comparing chat with the verified panel before sharing or starting fresh.Decision tree comparing chart and independent SQL, then comparing chat with the verified panel before sharing or starting fresh.
Check the current chart before treating an answer as stale. The branching decisions apply the panel and chart behavior documented by Datasette Agent and Datasette Charts.

Observation First check Next action
Daily values are 42 and 27 Those are the two-package sums for the fixture. Inspect the table filter and query source. Apply equality for the intended package and verify that both returned dates carry the single-package totals.
Both daily points are 1 The chart may be counting rows for the selected package. Inspect the aggregate, select a sum of downloads if available, and reopen the chart SQL to check the measure and both rows.
One bucket shows 30 for sqlite-utils The query may have combined both dates, for example by grouping by month. Check that the horizontal column is day. Try the finest date bucket offered, inspect the compiled grouping, and require separate results of 12 and 18.
The independent SQL returns zero rows Check the database and the parameter spelling, including the hyphen in sqlite-utils. Open the fixture table unfiltered, confirm the exact package values, then rerun the independent query with the right parameter.
Both chart rows match datasette, but the agent answers with 12 and 18 Check whether the panel shows the updated chart, the compiled SQL page, or the original chart. Return to the updated chart, verify datasette is selected, and ask again with the updated chart visible. If the reply remains stale, start a fresh chat.

If the chart goes blank after the switch, inspect the table before rebuilding. An earlier equality filter or search condition can still narrow the data. The plugin applies the table’s filters to the chart, so the row set can be empty even when the chart specification makes sense. Clear unrelated filters for this comparison. If the chart renders but its SQL link is unavailable, check execute-sql with the instance administrator. A table chart can render with view-table, while inspecting its compiled SQL requires execute-sql. Charts filters and permissions

When the dates disagree, inspect the source rows, time column and grouping first. When both dates appear with incorrect values, check the package predicate and the aggregate. Change one setting and read both date–value pairs again so you can tell which change resolved the discrepancy. If your build only produces a coarser bucket or the compiled query uses a different measure, keep the independent query result as the daily report and leave that chart unverified for the daily comparison. The same field-by-field check applies when comparing structured output with known source records. Verify structured output against local records

When the panel is correct and chat still describes the earlier chart, start a new conversation at /-/agent, tag the fixture #stats and send the original chart prompt with datasette in place of sqlite-utils in both occurrences. Open that generated chart in the new builder. Recheck the filter, date grouping and sum before using the same follow-up question. The new chat starts with the intended source and without the earlier inline chart in its history. If it still cannot establish the current view, write the summary from the checked SQL rows. If you want to reproduce the stale answer later, retain the actual prompt and reply with the panel filter and expected date–value pairs so someone can distinguish an answer mismatch from a chart mismatch. Sentry conversation exports and regression cases

Restore the first view and share the verified chart

  1. Open the first full chart URL you copied. Confirm the page is the fixture’s stats table with package = sqlite-utils. If the link opens the table without the intended chart, restore the package in the filter and use Build a chart if necessary to recreate the line on day with the previously verified grouping and sum. The recovery operates on the filtered view, so you can repeat it with the read-only analyst account. Chart URL fragments and table filters

  2. Run the independent query with sqlite-utils and verify the reopened chart gives 12 and 18 on the same dates. If you see 30 and 9, inspect the URL and table filter before touching the aggregation. Those are the known totals for the second package. If you restored the filter or chart manually, copy the full corrected address and reopen it once to confirm that it carries both settings.

  3. Share the full chart URL for the package you intend to report and include both verified date–value pairs. If you report the second view after restoring the first, use the datasette chart address and confirm its filter before sending. The following note is an illustrative example for that second view.

    Synthetic SQLite fixture, stats table. Package filter: datasette.
    Measure: sum of downloads per calendar day.
    2026-11-16: 30 downloads. 2026-11-17: 9 downloads.
    Daily downloads fell across the two dates.
    

A copied chart link preserves the view settings for someone who can access the table. The plotted results can change when the underlying data changes. The charts repository also says that an inline chat chart is drawn again from current data when a conversation is opened. Keep the checked rows alongside the report, and give the recipient the independent SQL, the parameter and the full chart link. If a later rerun returns different values, the saved rows tell them what the report used, and the query and link tell them which comparison to repeat. Datasette Charts chart links and chat rendering

For the training example, finish with the reopened sqlite-utils view showing 12 and 18 and a separate record for the datasette view showing 30 and 9. These records let a reader recover the original view without mistaking it for the reported one. The same distinction between a reopenable view and the values used in a report applies when checking analytics or keeping enough evidence to replay a result. Verify an analytics report · Preserve evidence for a replay

Sources

YOU'RE THROUGH THIS ONE.

Keep connecting the dots.

Back to the library

Many assistants.
One place to remember.

Bring your AI sessions, context, and usage together with Automater.

Meet Automater