# Datasette — Explore SQLite Data as Web UI + JSON API > Datasette turns any SQLite database into a browseable web UI + JSON API in one command. Publish to Vercel/Fly.io. Faceted + full-text search. ## Install Save as a script file and run: ## Quick Use 1. `pip install datasette` 2. `datasette serve your.db` — UI on localhost:8001 3. `datasette publish vercel your.db` to ship a public read-only data portal --- ## Intro Datasette is Simon Willison's open-source tool that turns any SQLite database into an instantly browseable web UI plus a full JSON API. Faceted filters, full-text search, pluggable rendering, and one-command publishing to Vercel, Fly.io, or Cloud Run. Best for: open-data publishing, internal data exploration, journalism investigations, anywhere CSV-as-tables beats hand-building dashboards. Works with: any SQLite file (or CSV via sqlite-utils ingestion). Setup time: 2 minutes. --- ### Install + run ```bash pip install datasette datasette serve fixtures.db --host 0.0.0.0 --port 8001 # open http://localhost:8001 ``` ### Publish to the cloud ```bash # Vercel datasette publish vercel fixtures.db --project=my-data # Fly.io datasette publish fly fixtures.db --app=my-data # Cloud Run datasette publish cloudrun fixtures.db --service=my-data ``` ### JSON API on every table ```bash curl http://localhost:8001/fixtures/products.json | jq '.rows[0]' # Filters, sort, search: curl 'http://localhost:8001/fixtures/products.json?category=Electronics&_sort_desc=price&_size=20' # Full-text search: curl 'http://localhost:8001/fixtures/products.json?_search=laptop' ``` ### Useful plugins | Plugin | Adds | |---|---| | `datasette-vega` | Charts directly from query results | | `datasette-auth-github` | GitHub OAuth gate | | `datasette-block-robots` | robots.txt blocking | | `datasette-render-images` | Inline image preview from blob columns | | `datasette-search-all` | Cross-table search | ### Why Simon's tool stack is influential Datasette has 9,700+ GitHub stars, powers public data portals from government and journalism orgs, and is the second-most-cited tool on simonwillison.net behind the LLM CLI. --- ### FAQ **Q: Can it handle Postgres, not just SQLite?** A: Not directly — Datasette is SQLite-first by design. For Postgres, use `db-to-sqlite` to mirror a subset, or use Datasette's plugin `datasette-postgres` for read-only views. Simon's stance: SQLite is enough for 95% of data publishing cases. **Q: How does it differ from Streamlit or Metabase?** A: Datasette is read-only by default, no JS to write, generates clean URLs for every row/filter (perfect for sharing). Streamlit is a Python app builder; Metabase is a self-hosted BI. Datasette is the tightest tool when 'just let me share this table' is the actual need. **Q: Plugins or full custom UI?** A: Both. Plugins extend rendering, auth, and query types via a documented API. For deeper customization, Datasette ships a Jinja-overridable template system. Most teams never need more than the built-in UI + 2-3 plugins. --- ## Source & Thanks > Built by [Simon Willison](https://github.com/simonw). Licensed under Apache-2.0. > > [simonw/datasette](https://github.com/simonw/datasette) — ⭐ 9,700+ --- ## 快速使用 1. `pip install datasette` 2. `datasette serve your.db` —— UI 在 localhost:8001 3. `datasette publish vercel your.db` 发布公开只读数据门户 --- ## 简介 Datasette 是 Simon Willison 开源的工具,把任何 SQLite 数据库瞬间变成可浏览的 web UI + 完整 JSON API。分面筛选、全文检索、插件渲染、一行命令发布到 Vercel / Fly.io / Cloud Run。适合开放数据发布、内部数据探索、新闻调查、任何「CSV 表」打败「手搓 dashboard」的场景。兼容任何 SQLite 文件(或通过 sqlite-utils 从 CSV 导入)。装机时间 2 分钟。 --- ### 安装 + 跑 ```bash pip install datasette datasette serve fixtures.db --host 0.0.0.0 --port 8001 # 打开 http://localhost:8001 ``` ### 发布到云 ```bash # Vercel datasette publish vercel fixtures.db --project=my-data # Fly.io datasette publish fly fixtures.db --app=my-data # Cloud Run datasette publish cloudrun fixtures.db --service=my-data ``` ### 每张表自带 JSON API ```bash curl http://localhost:8001/fixtures/products.json | jq '.rows[0]' # 筛选、排序、搜索: curl 'http://localhost:8001/fixtures/products.json?category=Electronics&_sort_desc=price&_size=20' # 全文检索: curl 'http://localhost:8001/fixtures/products.json?_search=laptop' ``` ### 常用插件 | 插件 | 增加什么 | |---|---| | `datasette-vega` | 查询结果直出图表 | | `datasette-auth-github` | GitHub OAuth 鉴权 | | `datasette-block-robots` | robots.txt 屏蔽 | | `datasette-render-images` | blob 列内联图片预览 | | `datasette-search-all` | 跨表搜索 | ### 为啥 Simon 的工具链有影响力 Datasette 在 GitHub 上 9,700+ 星,支撑政府和新闻机构的公开数据门户,是 simonwillison.net 引用次数仅次于 LLM CLI 的工具。 --- ### FAQ **Q: 能处理 Postgres,不只是 SQLite 吗?** A: 不能直接 —— Datasette 设计上 SQLite 优先。Postgres 用 `db-to-sqlite` 镜像子集,或用 `datasette-postgres` 插件做只读视图。Simon 的立场:95% 的数据发布场景 SQLite 够了。 **Q: 跟 Streamlit / Metabase 区别?** A: Datasette 默认只读、不写 JS、每行/筛选自动生成干净 URL(分享神器)。Streamlit 是 Python app 建造器;Metabase 是自托管 BI。需求只是「让我把这表分享出去」时 Datasette 最贴。 **Q: 插件还是完全自定义 UI?** A: 都行。插件通过文档化 API 扩展渲染、鉴权、查询类型。要更深定制 Datasette 自带可覆盖的 Jinja 模板系统。大多数团队内置 UI + 2-3 个插件就够。 --- ## 来源与感谢 > Built by [Simon Willison](https://github.com/simonw). Licensed under Apache-2.0. > > [simonw/datasette](https://github.com/simonw/datasette) — ⭐ 9,700+ --- Source: https://tokrepo.com/en/workflows/datasette-explore-sqlite-data-as-web-ui-json-api Author: Simon Willison