mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
/-/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>
This commit is contained in:
parent
1df4028d78
commit
8bc9b1ee03
7 changed files with 526 additions and 4 deletions
|
|
@ -142,7 +142,7 @@ async def test_database_page(ds_client):
|
|||
|
||||
# And a list of tables
|
||||
for fragment in (
|
||||
'<h2 id="tables">Tables</h2>',
|
||||
'<h2 id="tables">Tables',
|
||||
'<h3><a href="/fixtures/sortable">sortable</a></h3>',
|
||||
"<p><em>pk, foreign_key_with_label, foreign_key_with_blank_label, ",
|
||||
):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue