- Organizing complex queries in dedicated files
- Reusing the same query across multiple pages
- Keeping your markdown cleaner by separating SQL from content
Creating SQL Files
Create a new SQL file from the file tree sidebar by clicking the+ button on a directory and selecting “New SQL File”. SQL files use the .sql extension.
Write your query directly in the editor with full SQL autocomplete support:
Referencing SQL Files
From Components
Reference a SQL file in any component’sdata attribute using the file path:
From Inline Queries
Reference a SQL file from an inline query using the same syntax:Key Differences from Inline Queries
| Feature | SQL Files | Inline Queries |
|---|---|---|
| Location | Standalone .sql files | Embedded in markdown |
| Reusability | Can be used across multiple pages | Scoped to the page |
| Variable interpolation | Not supported | Supported |
Best Practices
- Use SQL files for shared queries: If you need the same data on multiple pages, put the query in a SQL file.
- Use inline queries for page-specific logic: For queries that use page filters or variables, inline queries are more flexible.
- Organize with directories: Create a
queries/directory to keep your SQL files organized. - Keep SQL files focused: Each file should contain a single, well-defined query.

