Claude Code (Opus 4.5) solved a column provenance problem for Datasette: given an arbitrary SQL query, map each result column back to its source table.column. This matters for Datasette because it would allow the tool to enrich query results with table-aware metadata, but the problem is harder than it looks. Joins, CTEs, and complex syntax all stand between a result column and its origin.

Claude found three distinct approaches. One uses apsw, the alternative Python SQLite binding. Another reaches into SQLite's C internals via ctypes to call sqlite3_column_table_name(), a function the standard Python sqlite3 module never exposes. The third interrogates the output of EXPLAIN. Three different layers of the stack, three different tradeoffs.

The full research writeup on GitHub is worth reading for the comparison between approaches, not just the winning answer. The ctypes solution in particular is the kind of thing most Python developers would never consider reaching for. Simon ran this with Opus 4.5 because Fable remains blocked under a US government directive issued June 13, 2026.

[READ ORIGINAL →]