Mapping SQLite result columns back to their source `table.column`
AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.
Why it matters
Developers running arbitrary SQLite queries can now programmatically trace every result column back to its originating table.column, enabling tools like Datasette to auto-annotate query output with provenance metadata.
Simon Willison explored how to find out which original table and column each piece of a SQLite database query result came from, even for complicated queries with joins and CTEs (temporary named query blocks). He used Claude Code, an AI coding tool, to test approaches. It matters to anyone building tools that show database query results with extra context. No dates or performance figures are given.
Willison's team at Datasette wants arbitrary SQL queries to display provenance information showing which source tables produced each result column. Claude Code (Opus 4.8) delivered three working approaches: the third-party apsw library's description_full, a ctypes bridge to the sqlite3_column_table_name() C function, and parsing EXPLAIN output. Costs are engineering time only; adoption is confined to projects needing SQLite column metadata.
SQLite exposes result-column provenance via its column-metadata API, but only when compiled with SQLITE_ENABLE_COLUMN_METADATA, and Python's built-in sqlite3 module never surfaces it. Claude Code (Opus 4.8) found three viable routes: apsw's cursor.description_full for direct access; a pure-stdlib ctypes bridge (column_provenance.py) calling sqlite3_column_table_name(); and interrogating EXPLAIN output. The goal is Datasette support for queries like joined users/orders selects, including CTEs.
Read the original
This summary exists to save you time, not to replace the source.
Key terms
Was this summary useful?
One click, anonymous. It tells us which summaries to re-run.
Related reading
Code-driven AI illustrations are more useful than images from dedicated image models
Code-driven AI illustrations let designers edit assets directly in code, saving time on iteration and ensuring consistency, which is a game-changer for teams that need rapid, reusable visual content.
A hierarchical note-taking app for building large personal knowledge bases
Trilium lets users build and navigate massive personal knowledge bases without duplicating content, saving time on organization and retrieval.
Desktop apps in Go with native UI or web frontend
Go developers can now ship cross-platform desktop and mobile apps in a single small binary without cgo or heavy runtimes, cutting build complexity and deployment size.
OpenBitFun: an agent workspace with four harness modes and phone remote control
OpenBitFun lets agents run on any machine and be controlled from a phone, eliminating the need to choose between local power and remote access, saving developers time switching contexts.
Intel One Mono: a monospaced font designed with low-vision developers
Developers with low vision or eye fatigue can read code more clearly, reducing errors and improving productivity.