---
type: Attested Computation
title: sql
identifier: data/sql
description: Run SQL queries on CSV, TSV, or tabular data, outputting results as Markdown, JSON, or CSV.
pack: data
tags:
- engineering
- computation
runtime: fragletc
image: ofthemachine/python3@sha256:a015b4f9f0e7c1648f8fcd4164f6a296dd3c9189404f88f333a9764d08d13522
network: none
stdin: buffer
execution_class: hermetic
procedure_hash: sha256:f957077b5e66031de53b9c249661a42586fbb8f7b91be298256343e90ba91d62
parameters:
- name: query
  type: string
  required: true
  description: SQL query to run against the table named 'data' (e.g. 'SELECT status, count(*) FROM data GROUP BY status')
- name: table_source
  type: file
  required: false
  description: Host CSV/TSV file mounted at /input/table_source
- name: table_text
  type: string
  required: false
  description: Inline CSV/TSV text (or pipe stdin)
- name: delimiter
  type: string
  required: false
  default: auto
  description: 'Column delimiter: auto, comma, tab, pipe, semicolon'
- name: format
  type: string
  required: false
  default: markdown
  description: 'Output format: markdown, json, csv'
computation: https://tools.ofthemachine.com/data/sql.py
executor:
  resource: https://github.com/ofthemachine/fraglet
  receipt:
  - schema
  - fragletc
  - procedure
  - procedure_hash
  - image
  - image_digest
  - network
  - stdin_mode
  - params
  - inputs
  - argv
  - env
  - memo_key
  - started
  - finished
  - exit_code
  - stdout
  - outputs
  format: fraglet-receipt/2 (fragletc --receipt <path>, or FRAGLETC_RECEIPT_DIR)
attester:
  resource: https://tools.ofthemachine.com/receipt/attest.py
  method: 'deterministic, no re-execution: procedure_hash equals sha256 of computation; memo_key recomputes from the receipt''s own fields; claimed params and any artifact hash match the receipt'
generated:
  by: process:tools/catalog/compile.py
  at: '2026-11-13T18:27:40Z'
---

# sql

Run SQL queries on CSV, TSV, or tabular data, outputting results as Markdown, JSON, or CSV.

Use when the user wants to query, filter, aggregate, or slice tabular CSV or TSV data with SQL, or large tabular files must be summarized before entering context.

# Schema

## Parameters
- `query` (string, required) — SQL query to run against the table named 'data' (e.g. 'SELECT status, count(*) FROM data GROUP BY status')
- `table_source` (file, optional) — Host CSV/TSV file mounted at /input/table_source
- `table_text` (string, optional) — Inline CSV/TSV text (or pipe stdin)
- `delimiter` (string, optional, default `auto`) — Column delimiter: auto, comma, tab, pipe, semicolon
- `format` (string, optional, default `markdown`) — Output format: markdown, json, csv
- stdin (optional) — piped input is read in full and hashed into the run's receipt

## Outputs
- stdout (the anonymous result)

# Execution

The computation is [`data/sql.py`](https://tools.ofthemachine.com/data/sql.py) (frontmatter `computation`; in `tools.tar.gz` the same file sits at `data/sql.py` beside this bundle), run by `fragletc` in `ofthemachine/python3@sha256:a015b4f9f0e7c1648f8fcd4164f6a296dd3c9189404f88f333a9764d08d13522` with network `none`. Its identity is `procedure_hash` = sha256 of that file, shebang included — the same value every receipt records. Parameters are passed as `-p name=value`; `--receipt run.json` (or `FRAGLETC_RECEIPT_DIR`) writes the receipt, a `fraglet-receipt/2` JSON document with the fields listed under `executor.receipt`.

# Attestation

A run's receipt is attested with [`receipt/attest.py`](https://tools.ofthemachine.com/receipt/attest.py): the computation that ran is this script (`procedure_hash`), the receipt is internally consistent (`memo_key` recomputes from its own fields), the claimed parameters are the ones that ran, and an artifact claimed as an output hashes to what the receipt recorded. No re-execution: attestation is provenance fidelity, not reproduction.

Hermetic: no network, so `memo_key` also fully determines the outputs — a re-run with the same inputs must reproduce them, which makes results from this tool safely memoizable.

Skill: [SKILL.md](https://tools.ofthemachine.com/data/SKILL.md)
