Skip to main content

SQL views over CSV files, with safe edits back to text.

Project description

LenzDB

SQL views over CSV files, with safe edits back to text.

LenzDB lets you define SQL views (called lenses) over CSV files, inspect them from the CLI, and safely write edits back to the source data. Everything stays as plain text, so Git works naturally.

Screen recording 2026-04-25 12.05.35 PM.webm


3-Minute Demo

# 1) Create a project with CSV data
mkdir demo && cd demo

cat > projects.csv <<EOF
id,name
p-1,Core Platform
p-2,Docs Refresh
EOF

cat > tasks.csv <<EOF
id,title,status,project_id
t-1,Ship CLI skeleton,todo,p-1
t-2,Write getting started docs,doing,p-2
t-3,Close phase zero,done,p-1
EOF

# tell LenzDB about the files
lnz add projects.csv
lnz add tasks.csv

# list tables LenzDB knows about
lnz list
# 2) Inspect your data
lnz view tasks
# 3) Define a lens (a saved SQL view)
cat > open_tasks.sql <<EOF
select
  t.id,
  t.title,
  t.status,
  p.name as project_name
from tasks t
join projects p on p.id = t.project_id
where t.status != 'done'
EOF

lnz view open_tasks
# 4) Edit through the view
export LENZDB_EDITOR="code --wait"   # or vim/nano
lnz edit open_tasks

Make a change (e.g. update a title or status), save, and close.

# 5) Changes are written back to the source CSV
cat tasks.csv

That’s the core idea:

  • Define the view you want to work with
  • Edit it
  • LenzDB safely writes changes back to CSV

Why

  • Keep data in simple, diffable CSV files
  • Use SQL to define the views people actually want
  • Edit projections, not raw tables
  • Review changes with normal Git diffs
  • Avoid the overhead of a full database

Install

pipx install lenzdb
# or
pip install lenzdb

Core Concepts

  • Tables → CSV files (tasks.csv)
  • Lenses → SQL views (open_tasks.sql)
  • lnz add → register a source table with LenzDB
  • lnz view → view a table or lens
  • lnz edit → modify a view; write changes back to source rows

Common Commands

lnz add
lnz list
lnz view tasks
lnz view open_tasks

lnz describe tasks
lnz explain open_tasks

lnz edit open_tasks
lnz edit tasks --filter "status = 'doing'"

lnz view tasks --filter "status = 'todo'"
lnz view tasks --columns id,title
lnz view tasks --order status,-title --limit 10

Optional: Explicit edit flow

lnz view open_tasks --format csv > /tmp/edit.csv
$EDITOR /tmp/edit.csv

lnz diff open_tasks /tmp/edit.csv
lnz plan open_tasks /tmp/edit.csv
lnz apply open_tasks /tmp/edit.csv

Project Structure (when you need it)

my-project/
  tasks.csv
  projects.csv
  open_tasks.sql

  .lenzdb/
    schema/
    policies/

You can ignore .lenzdb/ entirely to start.


Notes

  • CSV files are the source of truth
  • Lenses are just SQL files
  • Edits are validated before writeback
  • Writable views infer safe insert defaults from exact equality filters like where status = 'doing'
  • Keep your repo in Git for safety

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lenzdb-0.1.4.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lenzdb-0.1.4-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file lenzdb-0.1.4.tar.gz.

File metadata

  • Download URL: lenzdb-0.1.4.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for lenzdb-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8c207825471b6a034a69a97139ec95c7bc7d3ac875787ccbf4b1a401055d7a0b
MD5 c3f8a5ea988192c3415b18db55d1cd3e
BLAKE2b-256 0ec32abe451cafeef5f24b5cecb0410818285ecea46c6f4d00d1185db4d98667

See more details on using hashes here.

File details

Details for the file lenzdb-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: lenzdb-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for lenzdb-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5baed49c1a3c38eab40777b66cffb175fcf0e34200be0239b73190f5dc51bd1f
MD5 7b0ce1ba0dbae39396f1d61c8673d450
BLAKE2b-256 cfa83407e275b1e7851f644979f56738f3321256ac12b710918b23cedf891476

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page