datasette/datasette/views
Simon Willison 8bc9b1ee03
/-/schema and /db/-/schema and /db/table/-/schema pages (plus .json/.md)
* Add schema endpoints for databases, instances, and tables

Closes: #2586

This commit adds new endpoints to view database schemas in multiple formats:

- /-/schema - View schemas for all databases (HTML, JSON, MD)
- /database/-/schema - View schema for a specific database (HTML, JSON, MD)
- /database/table/-/schema - View schema for a specific table (JSON, MD)

Features:
- Supports HTML, JSON, and Markdown output formats
- Respects view-database and view-table permissions
- Uses group_concat(sql, ';' || CHAR(10)) from sqlite_master to retrieve schemas
- Includes comprehensive tests covering all formats and permission checks

The JSON endpoints return:
- Instance level: {"schemas": [{"database": "name", "schema": "sql"}, ...]}
- Database level: {"database": "name", "schema": "sql"}
- Table level: {"database": "name", "table": "name", "schema": "sql"}

Markdown format provides formatted output with headings and SQL code blocks.

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 12:01:23 -08:00
..
__init__.py Drop 3.8 testing, add 3.13 testing, upgrade Black 2025-03-09 20:45:18 -07:00
base.py Add /-/actions endpoint to list registered actions 2025-10-26 16:14:58 -07:00
database.py Add keyset pagination to allowed_resources() (#2562) 2025-10-31 14:50:46 -07:00
index.py Add keyset pagination to allowed_resources() (#2562) 2025-10-31 14:50:46 -07:00
row.py Fix type annotation bugs and remove unused imports 2025-10-26 16:03:13 -07:00
special.py /-/schema and /db/-/schema and /db/table/-/schema pages (plus .json/.md) 2025-11-07 12:01:23 -08:00
table.py Fix type annotation bugs and remove unused imports 2025-10-26 16:03:13 -07:00