Skip to content

spike: 005 export all tables of a SQLite file to CSV #12

Description

@iheitlager

Goal

First taste of V1's value ("open any .sqlite file, extract the data") as a working end-to-end tool, ahead of the real steps landing. Extends spike 002's reader (#4/#6) from one hardcoded table to: enumerate all tables via sqlite_master, walk each, and export every table as CSV.

Branch: spike/005_csv_export

Behavior

sqlite-rs-export path/to/mydata.db
# writes, next to the input file:
#   path/to/<table>_mydata.csv        (one per user table)
  • Output naming: <table>_<file>.csv (file = input basename without extension), written in the same folder as the input
  • All user tables from sqlite_master (skip sqlite_* internal tables; skip virtual tables with a warning — graceful unknowns per Tier 0)
  • Header row = column names from the minimal DDL read; rows in rowid order

What this spike de-risks (beyond spike 002)

Area Step it informs
Multi-table enumeration + root-page resolution from sqlite_master step 7 (minimal DDL reader)
Multi-page b-trees (interior nodes) on real data step 4
Overflow chains, if the chosen fixture has large values step 4
CSV value rendering: NULL representation, quoting/escaping, blob encoding (hex?), float formatting step 9 (output contract) — spike 002 finding 3 gets a concrete decision

Experiment (Atomic)

Throwaway crate under tests/spike/005_csv_export/, reusing spike 002's decoding sketch:

  1. Fixture: a db with 3+ tables, one multi-page (1000+ rows), one with all value types, one with a large TEXT/BLOB (overflow)
  2. Enumerate sqlite_master, resolve root pages + column names
  3. Walk each table b-tree recursively (interior → leaf), decode records
  4. Write CSVs; oracle-diff each against sqlite3 -csv "SELECT * FROM <t>"

Falsification criteria

Spike FAILS (valuably) if: interior-node traversal or overflow reassembly has undocumented surprises; or CSV parity with sqlite3 -csv is unreachable without semantic knowledge we don't have at Tier 0 (e.g. affinity-dependent rendering).

Out of scope

WAL (#7), locking (#8), UTF-16, WITHOUT ROWID, index b-trees. Loud asserts on all of these.

Timebox

1-2 days. Findings feed steps 4/7/9 ticket specs; the CSV rendering decisions go into the step 9 output contract.

Exit criteria

  • All tables of the fixture exported, sqlite3 -csv parity per table
  • Multi-page traversal + overflow exercised
  • CSV rendering decisions documented (NULL, quoting, blobs, floats)
  • findings.md + make spike-005

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    spikeExploratory/experimental spike work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions