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 and register 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 add open_tasks.sql
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 table or lens with a manifest in .lenzdb/schema/
  • lnz view → view a table or lens, even before it is registered
  • lnz edit → modify a table or lens; untracked resources are promoted on demand

Common Commands

lnz --help

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/

You can ignore .lenzdb/ entirely to start.


Notes

  • CSV files are the source of truth
  • Manifests in .lenzdb/schema/ register tracked tables and lenses
  • Resource names are literal, so dots in filenames are part of the name
  • Edits are validated before writeback
  • Writable views infer safe insert defaults from exact equality filters like where status = 'doing'
  • --page-size and $LENZDB_PAGE_SIZE > 0 turn on pagination and start at page 1 by default
  • 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.5.tar.gz (33.0 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.5-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lenzdb-0.1.5.tar.gz
  • Upload date:
  • Size: 33.0 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.5.tar.gz
Algorithm Hash digest
SHA256 ce62700dea3ae63ceeac8cfb8f69683956fe5556325e97beb460c7c3d3633ebe
MD5 ee20eecb33578ccfc496e1a63e820ceb
BLAKE2b-256 1170743d088532a697f8d3d819af0e0345a3e48049151c58c075afbab1e03159

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lenzdb-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 33.2 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 764a800d9ea9be4eda077385e8ad90f0c12d3ba8d2e036fb570a8cc6d0d14f92
MD5 9d9f8823f1df205db1d8f08696a42e40
BLAKE2b-256 ae842c5b745ffe0e8b8fdef0b9f43b2f356f7a5e61e7afb024afdbf038844460

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