Dynamic Block [[dynamic_block: SyntaxConcept]]SyntaxConcept
Description [[description: text]]textWorkspace Workspace 94%Run SQL Query ExtCommand 80%Open Preview ExtCommand 80%
Dynamic blocks execute SQL queries against workspace data and display results in documents. They are fenced code blocks with types like table, diagram, or chart, containing SQL queries or references to Query objects.
The parser stores code block metadata in __code_fences on __TextBlock objects. The workspace is loaded into an in-memory SQLite database for query execution.
Syntax [[syntax: text]]textWorkspace Workspace 88%Run SQL Query ExtCommand 85%CLI CLI 83%
Query objects define reusable SQL queries:
## Get Tables [[get_tables: Query]]
- sql: SELECT __id, __label FROM objects WHERE __kind = 'Table'
Reference to a Query object (inside a table code block):
query: [[#get_tables]]
Inline SQL (inside a table code block):
sql: SELECT __id, __kind FROM objects
Scope parameter:
scope: workspace(default) — auto-filters by current workspacescope: all— no workspace filtering, returns data from all workspaces
Renderers [[renderers: text]]text
| Type | Description |
|---|---|
table |
HTML table (implemented) |
diagram |
D2/Mermaid (future) |
chart |
Charts (future) |
Unknown type → raw YAML output.
Rules [[rules: text]]textWorkspace Workspace 73%Run Query from Block ExtCommand 70%YAML Block SyntaxConcept 65%
- Dynamic blocks live inside
__TextBlockobjects as fenced code blocks - Metadata is stored in
__code_fences(lang, offset_line, length_lines) - Query objects are regular QMD.md objects with a
sqlfield - The
scope: workspacedefault ensures data isolation between workspaces