cd /news/developer-tools/mapping-sqlite-result-columns-back-t… · home topics developer-tools article
[ARTICLE · art-26586] src=simonwillison.net ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Mapping SQLite result columns back to their source `table.column`

Simon Willison is researching methods to map SQLite query result columns back to their source table and column names, aiming to enhance Datasette's ability to render additional metadata for arbitrary SQL queries. He tasked Claude Code with finding solutions, which identified approaches using the apsw library, ctypes to access SQLite's internal C function, and analysis of EXPLAIN output.

read1 min publishedJun 13, 2026

Research: Mapping SQLite result columns back to their source table.column It would be neat if arbitrary SQL queries in Datasette could be rendered with additional information based on which columns from which tables were included in the results.

To build that, we would need to be able to look at a SQL query like select users.name, orders.total from users join orders on orders.user_id = users.id

and programmatically identify the table.column

for each result - navigating not just joins but also more complex syntax like CTEs. I decided to set Claude Code (Opus 4.8, since Fable is currently banned by the US government) on the problem. It found several promising solutions - one using apsw, another that uses ctypes

to access the SQLite sqlite3_column_table_name()

C function (which is not otherwise exposed to Python), and one using clever interrogation of the output of EXPLAIN

.

── more in #developer-tools 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/mapping-sqlite-resul…] indexed:0 read:1min 2026-06-13 ·