### Install Project Dependencies
Source: https://hypersphere.blog/sql-seal/contributing/project-setup
Installs all necessary project dependencies using pnpm. This command should be run after cloning the repository.
```bash
pnpm install
```
--------------------------------
### Run Project Tests
Source: https://hypersphere.blog/sql-seal/contributing/project-setup
Executes the project's test suite to verify the setup and ensure everything is functioning correctly. Green checks indicate a successful setup.
```bash
pnpm test
```
--------------------------------
### Joining Data from Different Files (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
An example demonstrating how to join data from two different markdown files. It queries monthly sales and targets, calculates the achievement percentage, and orders the results by month.
```sql
TABLE sales = table(file:Data/sales.md, Monthly Sales)
TABLE targets = table(file:Plans/targets.md, Monthly Targets)
SELECT
s.Month,
s.Revenue,
t.Target,
ROUND((s.Revenue / t.Target) * 100, 1) as Achievement
FROM
sales s
JOIN
targets t ON s.Month = t.Month
ORDER BY
s.Month
```
--------------------------------
### Reference Table using Relative File Paths (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Provides examples of referencing tables in other files using relative paths, including referencing tables in subfolders or parent folders of the current file.
```sql
-- Same folder, reports subfolder
TABLE data = table(file:./reports/q1.md, 0)
-- Parent folder
TABLE summary = table(file:../summary.md, 0)
```
--------------------------------
### Analyzing Data Under Different Headers (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
This example shows how to aggregate revenue data from tables located under different headers (quarters) in potentially different notes. It uses UNION ALL to combine the results into a single summary.
```sql
TABLE q1 = table(Q1 Results)
TABLE q2 = table(Q2 Results)
TABLE q3 = table(Q3 Results)
TABLE q4 = table(Q4 Results)
SELECT
'Q1' as Quarter, SUM(Revenue) as Revenue FROM q1
UNION ALL
SELECT
'Q2' as Quarter, SUM(Revenue) as Revenue FROM q2
UNION ALL
SELECT
'Q3' as Quarter, SUM(Revenue) as Revenue FROM q3
UNION ALL
SELECT
'Q4' as Quarter, SUM(Revenue) as Revenue FROM q4
ORDER BY
Quarter
```
--------------------------------
### Clone SQLSeal Repository
Source: https://hypersphere.blog/sql-seal/contributing/project-setup
Clones the SQLSeal project repository from GitHub. This is the first step to setting up the project locally for development.
```bash
git clone git@github.com:h-sphere/sql-seal.git
```
--------------------------------
### Expense Summary by Month and Category (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
An example of summarizing expenses by month and category. It queries the first table in the note, formats the date to 'YYYY-MM', groups the data, and orders it by month and total amount.
```sql
TABLE expenses = table(0)
SELECT
strftime('%Y-%m', Date) as Month,
Category,
ROUND(SUM(Amount), 2) as Total
FROM
expenses
GROUP BY
Month, Category
ORDER BY
Month, Total DESC
```
--------------------------------
### Build Project
Source: https://hypersphere.blog/sql-seal/contributing/project-setup
Compiles the TypeScript and WASM files into a single 'main.js' file. This command is used to build the plugin for use or testing.
```bash
pnpm build
```
--------------------------------
### Link Plugin to Obsidian Vault
Source: https://hypersphere.blog/sql-seal/contributing/project-setup
Creates a symbolic link to the cloned repository within the Obsidian plugins folder. This allows for easier development by directly linking the code to the vault.
```bash
ln -s ../cloned-location sqlseal
```
--------------------------------
### Advanced SQLSeal Example with Goodreads Data
Source: https://hypersphere.blog/sql-seal/links-and-images
An advanced example demonstrating SQLSeal's capabilities by fetching book data from a CSV, creating links to Open Library, displaying book covers, and filtering by author using Obsidian properties. It includes type casting for ISBN numbers.
```sql
TABLE books = file(books.csv)
SELECT
a(title, 'https://openlibrary.org/isbn/' || CAST(isbn13 as int)) as title,
authors,
img('https://covers.openlibrary.org/b/isbn/' || CAST(isbn13 as INT) || '-L.jpg') as cover FROM books
WHERE authors
LIKE '%' || @author || '%'
LIMIT 10
```
--------------------------------
### SQLSeal Query Configuration Example
Source: https://hypersphere.blog/sql-seal/query-configuration
Demonstrates the basic structure for configuring a SQLSeal query. It includes table definition, refresh settings, explain statement, and a final select statement.
```sqlseal
TABLE data = file(data.csv)
REFRESH
EXPLAIN
GRI D
SELECT * FROM data
```
--------------------------------
### Handlebars Template Rendering Example
Source: https://hypersphere.blog/sql-seal/renderers/template
This example demonstrates how to use Handlebars templating with the SQLSeal Template Renderer. It shows how to access file properties and iterate over query results to generate HTML. The data from the SELECT statement is available as the 'data' variable, and file properties are in 'properties'.
```Handlebars
TEMPLATE
Current Path: {{properties.path}}
{{#each data}}
{{path}}
{{/each}}
SELECT * FROM files LIMIT 10
```
--------------------------------
### SQL-Seal Basic Pie Chart
Source: https://hypersphere.blog/sql-seal/charts/types/pie-chart
This snippet demonstrates how to create a basic pie chart using SQL-Seal. It assumes a 'finances' table with data suitable for pie chart representation.
```SQL-Seal
TABLE finances = table(0)
CHART {
series: [{
type: 'pie'
}]
}
SELECT * FROM finances
```
--------------------------------
### Reference Table from Another File by Index (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Demonstrates how to query a table located in a different markdown file using the `file:` prefix followed by the file path and the table's numeric index.
```sql
TABLE expenses = table(file:Finance/expenses.md, 0)
```
--------------------------------
### Reference Table by Index (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Demonstrates referencing the first table in a note using its numeric index (0). This method is simple but can break if the table order changes.
```sql
TABLE expenses = table(0)
SELECT * FROM expenses
```
--------------------------------
### SQL NATURAL JOIN Example
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.24.1 adds `path` columns to `tags` and `tasks` tables, enabling the use of `NATURAL JOIN` for connecting them.
```sql
SELECT t.tag_name, ts.task_description
FROM tags AS t
NATURAL JOIN tasks AS ts;
```
--------------------------------
### Get all files from the vault
Source: https://hypersphere.blog/sql-seal/query-vault-content
Retrieves all entries from the 'files' table, effectively listing all files in the vault.
```sql
SELECT * FROM files
```
--------------------------------
### Query Markdown Tables with Formatting
Source: https://hypersphere.blog/sql-seal/query-markdown-tables
This example shows querying a markdown table and applying formatting (rounding) to the aggregated results. It uses the `table(0)` reference for the data source.
```sql
TABLE expenses = table(0)
SELECT date, ROUND(SUM(Amount), 2) as Spent
FROM expenses
GROUP BY date
```
--------------------------------
### Reference Tables by Header and Index (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Illustrates referencing tables when multiple tables exist under the same header. It shows referencing by subheader name directly or by the parent header combined with a numeric index to specify the desired table.
```sql
-- By subheader
TABLE revenue = table(Revenue by Category)
TABLE expenses = table(Expense Breakdown)
-- Or by parent header and index
TABLE revenue = table(Financial Data, 0) -- First table under Financial Data
TABLE expenses = table(Financial Data, 1) -- Second table under Financial Data
```
--------------------------------
### Execute Inline SQL Query for Average Sale
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Shows how to embed a SQL query to find the average sale amount, rounded to two decimal places. Table definitions must be provided externally.
```sql
S> SELECT ROUND(AVG(Amount), 2) FROM transactions
```
--------------------------------
### Reference Table from Another File by Header (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Shows how to reference a table in another file by specifying the file path and the header under which the table resides. An optional index can be appended if multiple tables share the same header in the target file.
```sql
TABLE summary = table(file:Finance/annual-report.md, Revenue Summary)
TABLE revenue = table(file:Finance/annual-report.md, Financial Data, 0)
TABLE expenses = table(file:Finance/annual-report.md, Financial Data, 1)
```
--------------------------------
### Execute Inline SQL Query for Total Revenue
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Demonstrates embedding a SQL query to calculate the total revenue directly within the text. This requires table definitions to be present elsewhere in the document.
```sql
S> SELECT SUM(Revenue) FROM sales
```
--------------------------------
### Query All Files in Obsidian Vault
Source: https://hypersphere.blog/sql-seal/index
This SQL query retrieves all files from the vault, ordered by modification date in descending order, and limits the results to the 10 most recently modified files. It's a basic example to get started with querying vault data.
```sql
SELECT * FROM files
ORDER BY modified_at DESC
LIMIT 10
```
--------------------------------
### SQL-Seal Ring Style (Doughnut) Chart
Source: https://hypersphere.blog/sql-seal/charts/types/pie-chart
This example shows how to create a doughnut-style chart by specifying inner and outer radii for the pie series in SQL-Seal. This visually represents data with a hole in the center.
```SQL-Seal
TABLE finances = table(0)
CHART {
series: [{
type: 'pie',
radius: ['40%', '70%']
}]
}
SELECT * FROM finances
```
--------------------------------
### Reference Table by Header (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Shows how to reference a markdown table using the header text preceding it. This method is more resilient to changes in table order within the document. The reference is case-insensitive.
```sql
TABLE expenses = table(Monthly Expenses)
```
--------------------------------
### Reference Table with Optional File Extension (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/markdown-tables
Illustrates that the `.md` file extension is optional when referencing tables from other files; SQL Seal will automatically append it during the lookup process.
```sql
TABLE data = table(file:Finance/reports/q1, 0) -- Will look for q1.md
```
--------------------------------
### Filter files by a specific property value
Source: https://hypersphere.blog/sql-seal/query-vault-content
Filters files based on a frontmatter property. This example selects files where the 'type' property is set to 'resource'. SQLSeal automatically creates columns for properties.
```sql
SELECT * FROM files WHERE type = 'resource'
```
--------------------------------
### Customize AG Grid with Default Column Definitions
Source: https://hypersphere.blog/sql-seal/changing-render-method
Allows customization of the Grid view's default column behavior by passing AG Grid's `defaultColDef` object. This example enables text filtering and column stretching for all columns. Configuration accepts simple objects only, excluding functions or variables.
```SQLSeal
TABLE data = file(./data.csv)
GRID {
defaultColDef: {
filter: "agTextColumnFilter",
flex: 1
}
}
SELECT * FROM data
LIMIT 100
```
--------------------------------
### SQLSeal Radar Chart for Daily Routines
Source: https://hypersphere.blog/sql-seal/charts/types/radar
This code snippet uses SQLSeal to create a radar chart. It defines indicators for different aspects of daily routines, such as 'Sleep quality', 'Productivity', 'Exercise', 'Nutrition', 'Mood', and 'Social Connections', setting a maximum value of 100 for each. The chart is configured with a polygon shape and a split number of 6, with area styling for the radar series.
```sqlseal
TABLE data = table(0)
CHART {
radar: {
indicator: [
{ name: 'Sleep quality', max: 100 },
{ name: 'Productivity', max: 100 },
{ name: 'Excercise', max: 100 },
{ name: 'Nutrition', max: 100 },
{ name: 'Mood', max: 100 },
{ name: 'Social Connections', max: 100 },
],
shape: 'polygon',
splitNumber: 6,
},
series: [{
type: 'radar',
areaStyle: { opacity: 0.2 }
}]
}
SELECT * FROM data
```
--------------------------------
### SQL-Seal Nightingale Chart (Rose Chart)
Source: https://hypersphere.blog/sql-seal/charts/types/pie-chart
This snippet illustrates how to generate a Nightingale chart (also known as a rose chart) in SQL-Seal by setting the 'roseType' to 'area'. This chart type emphasizes proportions by varying the area of chart segments.
```SQL-Seal
TABLE finances = table(0)
CHART {
series: [{
type: 'pie',
roseType: 'area'
}]
}
SELECT * FROM finances
```
--------------------------------
### Query tables in notes with SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
Starting from version 0.16.0, SQLSeal allows users to query tables directly within their notes, using them as data sources. This feature significantly expands the plugin's capabilities by enabling more complex data manipulation and integration within the Obsidian vault. Further details can be found in the official documentation.
```SQLSeal
SELECT * FROM "your_note_table" WHERE condition;
```
--------------------------------
### Introduce SQLSeal Explorer
Source: https://hypersphere.blog/sql-seal/changelog
Adds the SQLSeal Explorer, a new interface designed to simplify the process of working with and managing SQL queries within the application.
```git
531d486: Added SQLSeal Explorer that makes it easy to work on new queries
```
--------------------------------
### SQL Query Link Syntax
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.24.0 and 0.23.0 enhance how links are handled within SQL queries. Links can now be specified using `a(href)` or `a(href, name)` syntax, and support for wikilinks within the `a` function is also included.
```sql
SELECT a(href='https://example.com') AS external_link FROM files;
SELECT a(href='[[wikilink]]', name='Internal Link') AS wikilink_example FROM files;
```
--------------------------------
### Enable TEMPLATE renderer features
Source: https://hypersphere.blog/sql-seal/changelog
Extends the TEMPLATE renderer to support checkboxes, links, and images, similar to other views, providing consistent feature parity.
```git
feat: TEMPLATE renderer can now use checkboxes, links and images like other views.
```
--------------------------------
### YAML Frontmatter with Tags in Obsidian
Source: https://hypersphere.blog/sql-seal/faq/understanding-tags
Demonstrates how to define tags within the YAML frontmatter of an Obsidian file. These tags are treated as a list of values and are accessible via the files table in SQLSeal.
```yaml
---
tags: [project, todo]
---
```
--------------------------------
### Reference tables from other files
Source: https://hypersphere.blog/sql-seal/changelog
Enables the referencing of tables from different files within `table()` functions, improving data modularity and cross-file accessibility.
```git
feat: added ability to reference tables from the other files in `table()` functions
```
--------------------------------
### Add TEMPLATE view for Handlebars
Source: https://hypersphere.blog/sql-seal/changelog
Introduces a new TEMPLATE view that allows rendering templates using custom Handlebars templates, offering flexible content presentation.
```git
Added TEMPLATE view that allow to render your template with custom Handlebars template.
```
--------------------------------
### Inline SQLSeal queries using S> prefix
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.14.0 introduced support for inline code blocks in SQLSeal. By using a backtick (`) and the prefix `S>`, users can now embed SQLSeal queries directly within their notes, making it easier to document and execute SQL commands in context.
```SQLSeal
`S> SELECT name, email FROM users;`
```
--------------------------------
### Add text rendering for Markdown
Source: https://hypersphere.blog/sql-seal/changelog
Enhances the Markdown renderer by adding text rendering capabilities for links, images, and checkboxes, improving content display.
```git
feat: added text rendering for links, images and checkboxes (for MARKDOWN renderer)
```
--------------------------------
### Highlight code in copy modal
Source: https://hypersphere.blog/sql-seal/changelog
Implements syntax highlighting for code displayed within the copy modal, improving readability when copying code snippets.
```git
531d486: highlighting code in the copy modal
```
--------------------------------
### Preview SQLite databases with explorer view
Source: https://hypersphere.blog/sql-seal/changelog
Introduces the capability to preview SQLite databases using the explorer view, facilitating easier data inspection and management.
```git
531d486: sqlite databases can now be previewed using explorer view
```
--------------------------------
### Interactive SQL schema visualizer
Source: https://hypersphere.blog/sql-seal/changelog
Implements an interactive visualizer for the SQL schema of external databases, aiding in understanding database structures and relationships.
```git
403e9f3: added interactive visualiser for SQL schema of external databases
```
--------------------------------
### Improve minimal theme custom classes support
Source: https://hypersphere.blog/sql-seal/changelog
Enhances the support for custom classes within the minimal theme, allowing for more flexible and customized user interface appearances.
```git
feat: improved support for minimal theme custom classes
```
--------------------------------
### Add syntax highlighting for JavaScript
Source: https://hypersphere.blog/sql-seal/changelog
Introduces syntax highlighting for JavaScript code, specifically intended for use with the GRAPH view, improving code readability.
```git
Adding syntax highlighting for javascript (to be used with GRAPH view)
```
--------------------------------
### Reference tables by header name
Source: https://hypersphere.blog/sql-seal/changelog
Allows tables to be referenced using their header names, providing a more intuitive and readable way to access table data.
```git
feat: added ability to reference tables by their header name
```
--------------------------------
### Query Markdown Tables by Index
Source: https://hypersphere.blog/sql-seal/query-markdown-tables
This snippet demonstrates how to reference the first markdown table (index 0) in the current note and then query it using SQL syntax. It's useful for quick analysis of data within a single document.
```sql
TABLE expenses = table(0)
SELECT date, SUM(Amount) as Total
FROM expenses
GROUP BY date
```
--------------------------------
### Navigate to linked CSV and JSON file sources
Source: https://hypersphere.blog/sql-seal/changelog
Introduces the ability to navigate directly to the source files (CSV and JSON) that are linked within the application, improving data traceability.
```git
feat: you can now navigate to linked CSV and JSON file sources
```
--------------------------------
### Split styles into separate files
Source: https://hypersphere.blog/sql-seal/changelog
Refactors the project by splitting CSS styles into separate files, enhancing maintainability and organization of the styling code.
```git
1d2fba6: chore: splitting styles into separate files for easier maintainance
```
--------------------------------
### Add support for .sql and .sqlseal files
Source: https://hypersphere.blog/sql-seal/changelog
This change introduces support for new file extensions, .sql and .sqlseal, allowing these files to be recognized and processed by the SQLSeal functionality.
```git
c4278c2: adding support for .sql and .sqlseal files
```
--------------------------------
### Rework JSONViewer for JSONPath preview
Source: https://hypersphere.blog/sql-seal/changelog
Refactors the JSONViewer component to include a visual preview of JSONPath expressions, improving the usability of JSON data manipulation.
```git
1bf5e8e: reworked JSONViewer to allow for visual JSONPath preview
```
--------------------------------
### Configure default page size for GRID view
Source: https://hypersphere.blog/sql-seal/changelog
Allows users to configure the default page size for the GRID view, providing control over the amount of data displayed per page.
```git
Added ability to configure default page size for the GRID view
```
--------------------------------
### Query Links within a Specific Frontmatter Property (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/vault-data
This SQL query lists files that link to the current file via a specific frontmatter property (e.g., 'type'). It selects distinct source file paths from the 'links' table, filtering by the target file and the specified 'frontmatterKey'.
```sql
LIST
SELECT a(path) FROM links
WHERE target = @path
AND json_extract(position, '$.frontmatterKey') = 'type'
```
--------------------------------
### Render Links with SQLSeal
Source: https://hypersphere.blog/sql-seal/links-and-images
Displays clickable links in query results using the 'a' SQL function. It can take an optional second parameter for the link's display name. This function is compatible with filesystem and CSV data.
```sql
SELECT a(path) FROM files LIMIT 10
```
```sql
SELECT a(path, name) from files LIMIT 10
```
--------------------------------
### SQL Syntax Highlighting and Comments
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.27.0 introduces improved syntax highlighting for SQL queries, specifically targeting query parts. It also adds support for SQL comments, including single-line (`--`) and multi-line (`/* */`) styles.
```sql
-- This is a single-line comment
SELECT column1, column2
FROM my_table;
/* This is a multi-line comment
that spans across several lines */
SELECT * FROM another_table;
```
--------------------------------
### Query Links in File Body (SQL)
Source: https://hypersphere.blog/sql-seal/data-sources/vault-data
This SQL query finds all links within the body of a note that point to the current file. It filters the 'links' table by matching the 'target' column to the current file's path and ensuring 'frontmatterKey' is NULL in the 'position' JSON.
```sql
SELECT * FROM links
WHERE target = @path
AND json_extract(position, '$.frontmatterKey') IS NULL
```
--------------------------------
### Render lists properly
Source: https://hypersphere.blog/sql-seal/changelog
Fixes an issue where lists were not being rendered as expected, ensuring proper display of list elements.
```git
fix: lists are now rendered properly (by @satkowski)
```
--------------------------------
### Improve table and chart rendering
Source: https://hypersphere.blog/sql-seal/changelog
Enhances the rendering of tables and charts on the canvas, ensuring they function correctly even when using external files.
```git
285684d: tables and charts now render better on canvas and work when you use external files too
```
--------------------------------
### Define and Query CSV Data with SQLSeal
Source: https://hypersphere.blog/sql-seal/quick-start
This snippet demonstrates how to define a table from a CSV file named 'transactions.csv' and then execute a SQL SELECT query to retrieve specific columns ('name', 'value') from that table.
```sqlseal
TABLE transactions = file(transactions.csv)
SELECT name, value FROM transactions
```
--------------------------------
### Render LIST views as regular lists
Source: https://hypersphere.blog/sql-seal/changelog
Changes the rendering of LIST views with a single column to appear as regular lists instead of nested ones, improving readability.
```git
feat: LIST views with single column are rendered as a regular list (rather than nested one) (by @kDCYorke)
```
--------------------------------
### Embed Images with SQLSeal
Source: https://hypersphere.blog/sql-seal/links-and-images
Embeds images directly into query results using the 'img' SQL function. For local images stored in Obsidian, the original note's path must be provided as a second parameter.
```sql
SELECT name, img(coverImg) FROM files
```
```sql
SELECT path, img(cover, path) FROM files
```
--------------------------------
### Allow external plugins to register flags
Source: https://hypersphere.blog/sql-seal/changelog
Enables external plugins to register flags, providing a mechanism for additional configuration options and extending the plugin's functionality.
```git
Technical:
* Other plugins can now register flags to allow for extra configuration
```
--------------------------------
### Improve grid resizing behavior
Source: https://hypersphere.blog/sql-seal/changelog
Enhances the grid resizing functionality, making it more responsive and reliable when switching tabs or resizing the Obsidian window.
```git
fix: grid resizing now works better when switching tabs, resizing obsidian, etc.
```
--------------------------------
### Add global tables support in SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
Enables the definition of global tables that can be accessed across all files within the SQLSeal environment, enhancing data accessibility and reusability.
```git
2bfd206: adding global tables support - you can now define table that will be available in all your files
```
--------------------------------
### JSON and JSON5 File Querying
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.19.0 adds support for querying JSON and JSON5 files. It allows traversal using JSONPath to extract data and create tables from these file types.
```sql
SELECT JSON_EXTRACT(json_data, '$.propertyName') AS extracted_value FROM json_files_table;
```
--------------------------------
### Link to JSON/JSON5 File in SQLSeal
Source: https://hypersphere.blog/sql-seal/data-sources/json-and-json5
Demonstrates how to link a JSON or JSON5 file as a data source in SQLSeal. It specifies the table alias and the file path, with an optional JSONPath argument to select specific data.
```SQLSeal
TABLE data = file(path.json, $.results[*])
```
--------------------------------
### Template view can access file properties
Source: https://hypersphere.blog/sql-seal/changelog
Enables the Template view to access and utilize file properties, allowing for dynamic content generation based on file metadata.
```git
Feat: Template view can now access file properties
```
--------------------------------
### Add heading and heading_level to tasks table
Source: https://hypersphere.blog/sql-seal/changelog
Introduces new columns, `heading` and `heading_level`, to the tasks table, providing hierarchical information about task locations.
```git
feat: new heading and heading_level columns in tasks table (by @kDCYorke)
```
--------------------------------
### Add basename and parent SQL variables
Source: https://hypersphere.blog/sql-seal/changelog
Introduces new SQL variables, `basename` and `parent`, which can be used within SQL queries to access file-related information.
```git
feat: added basename and parent SQL variables
```
--------------------------------
### Expose filename in renderer
Source: https://hypersphere.blog/sql-seal/changelog
Makes the filename accessible within the renderer, allowing for context-aware rendering based on the current file.
```git
chore: exposing filename in the renderer (by @satkowski)
```
--------------------------------
### Improve text links for images
Source: https://hypersphere.blog/sql-seal/changelog
Enhances the rendering of text links that point to images, ensuring they are displayed and function correctly.
```git
fix: better text links for images (by @satkowski)
```
--------------------------------
### Organize plugin code into modules
Source: https://hypersphere.blog/sql-seal/changelog
Restructures the plugin's internal codebase by organizing code into modules, aiming for better maintainability and code management.
```git
285684d: reworking plugin internals to organise code into modules
```
--------------------------------
### Select Tags of Current File using @path
Source: https://hypersphere.blog/sql-seal/using-properties
This SQL query retrieves tags associated with the current file by filtering the 'tags' table based on the file's path. It uses the '@path' built-in variable.
```sql
SELECT * FROM tags WHERE path = @path
```
--------------------------------
### Update dependencies
Source: https://hypersphere.blog/sql-seal/changelog
Updates project dependencies to their latest available versions, ensuring the project utilizes current libraries and frameworks.
```git
chore: updated dependencies to the latest versions
```
--------------------------------
### Expose frontmatter links in links table
Source: https://hypersphere.blog/sql-seal/changelog
Makes frontmatter links accessible within the links table, allowing for easier querying and management of inter-document links.
```git
feat: frontmatter links are now exposed in links table (by @kDCYorke)
```
--------------------------------
### Enable external plugin cellRenderer usage
Source: https://hypersphere.blog/sql-seal/changelog
Allows external plugins to utilize the cellRenderer from the main plugin, facilitating custom cell rendering and integration.
```git
chore: now external plugins can use cellRenderer from the main plugin
```
--------------------------------
### Render SQL Results as HTML List
Source: https://hypersphere.blog/sql-seal/renderers/list
Renders SQL query results as HTML unordered lists () with list items (- ) for each row. Each row is represented as a nested list. This renderer does not include default styling.
```sqlseal
LIST
SELECT name, path FROM files LIMIT 10
```
--------------------------------
### Add SQL variables for file paths
Source: https://hypersphere.blog/sql-seal/changelog
Introduces new SQL variables: `@path`, `@fileName`, and `@extension`. These can be used within SQL queries alongside other Frontmatter properties to access file-specific information.
```git
Added @path, @fileName and @extension variables you can use inside your SQL alongside other Frontmatter properties
```
--------------------------------
### Improve syntax highlighting with error indication
Source: https://hypersphere.blog/sql-seal/changelog
Enhances syntax highlighting by visually indicating lines with errors using appropriate colors, making it easier to identify and fix issues.
```git
Improved syntax highlighting - now lines with errors will get highlighted with appropriate colour to indicate the issue
```
--------------------------------
### Import filenames with spaces
Source: https://hypersphere.blog/sql-seal/changelog
Resolves an issue where imported filenames containing spaces were not handled correctly, ensuring proper file import regardless of filename composition.
```git
8e1a879: fix: imported filenames can now contain spaces
```
--------------------------------
### Interactive Task Checkboxes with SQLSeal
Source: https://hypersphere.blog/sql-seal/links-and-images
Demonstrates two methods for creating interactive task checkboxes. The recommended method uses a direct 'checkbox' column for cleaner queries. An alternative method uses the 'checkbox' function with numeric or boolean values, resulting in disabled checkboxes.
```sql
SELECT checkbox, task FROM tasks
```
```sql
-- Using the checkbox column
SELECT task, checkbox(completed) FROM tasks
```
--------------------------------
### SQL Comments: Line and Block in SQLSeal
Source: https://hypersphere.blog/sql-seal/comments
Demonstrates the use of both line comments (-- ) and block comments (/* */) within SQLSeal queries. Comments are used to document code, disable query parts, and control execution.
```SQLSeal
TABLE a = file(file.csv)
-- TABLE b = file(file2.csv)
/*
GRID
NO REFRESH
*/
SELECT *
FROM a
-- WHERE value > 5
```
--------------------------------
### Define default view for SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
Adds the ability to set a default view (Grid, HTML, or Markdown) for SQLSeal, streamlining the user experience by pre-selecting a preferred display mode.
```git
Added ability to define default view (Grid, HTML or Markdown)
```
--------------------------------
### Render SQLSeal results on canvas
Source: https://hypersphere.blog/sql-seal/changelog
Ensures that SQLSeal query results are rendered correctly on the canvas, providing a seamless visualization experience.
```git
fix: SQLSeal results are now properly rendered on canvas
```
--------------------------------
### SQL Execution Plan
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.22.3 provides an advanced feature to display the SQL execution plan for a given query.
```sql
EXPLAIN QUERY SELECT * FROM my_table;
```
--------------------------------
### SQLSeal's TABLE syntax without SELECT
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.10.1 restored the ability to use the `TABLE` syntax in SQLSeal without requiring a preceding `SELECT` statement. This simplifies queries when you only intend to view the contents of a table.
```SQLSeal
TABLE my_data;
```
--------------------------------
### Select Current File using @path
Source: https://hypersphere.blog/sql-seal/using-properties
This SQL query selects all columns from the 'files' table where the 'path' column matches the current file's path. It utilizes the '@path' built-in variable.
```sql
SELECT * FROM files WHERE path = @path
```
--------------------------------
### Create Mixed Line and Bar Chart with Tooltip - SQLSeal
Source: https://hypersphere.blog/sql-seal/charts/types/mixed-charts
This SQLSeal code configures a chart to display temperature as a line and rainfall as a bar chart. It uses two y-axes for different scales and includes a crosshair tooltip for data inspection. The chart is configured to use 'month' for the x-axis, 'max_temp' for the line chart on the left y-axis, and 'rainfall' for the bar chart on the right y-axis.
```SQLSeal
TABLE t = table(0)
CHART {
xAxis: { type: 'category' },
yAxis: [
{
type: 'value',
name: 'Temperature',
min: 0,
max: 25,
position: 'left',
axisLabel: {
formatter: '{value} °C'
}
},
{
type: 'value',
name: 'Rainfall',
min: 0,
max: 180,
position: 'right',
axisLabel: {
formatter: '{value} mm'
}
}
],
series: [
{
name: 'Temperature',
type: 'line',
smooth: true,
yAxisIndex: 0,
},
{
name: 'Rainfall',
type: 'bar',
yAxisIndex: 1,
encode: { y: 'rainfall' },
}
],
tooltip: {
trigger: 'axis',
axisPointer: { type: 'cross' }
},
legend: {},
}
SELECT month, max_temp, rainfall FROM t
```
--------------------------------
### Advanced SQL syntax support in SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
SQLSeal's SQL parser was significantly upgraded in version 0.15.0 to support more complex syntax, including recursive Common Table Expressions (CTEs) and window functions. This migration from `node-sql-parser` to `sql-parser-cst` provides a more robust and feature-rich SQL querying experience.
```SQLSeal
WITH RECURSIVE cte AS (
SELECT 1 as n
UNION ALL
SELECT n + 1 FROM cte WHERE n < 5
) SELECT * FROM cte;
```
--------------------------------
### Style Specific Fields in List Renderer
Source: https://hypersphere.blog/sql-seal/renderers/list
Demonstrates how to style individual fields within the list renderer by targeting the `data-sqlseal-column` attribute set on list elements. This allows for granular control over the appearance of specific data points.
```css
.sqlseal-list-element-single[data-sqlseal-column="name"] {
background: red;
}
```
--------------------------------
### Display Column Names in List Renderer Output
Source: https://hypersphere.blog/sql-seal/renderers/list
Enables the display of column names within the rendered list output by applying the `.show-column-names` class. This provides context for each data field.
```sqlseal
LIST .show-column-names
SELECT name, path FROM Files
```
--------------------------------
### Custom SQL functions for links and images in SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.8.0 introduced custom SQL functions `a` and `img` in SQLSeal, allowing users to embed links and images (both local and external) directly within their query results. This enriches the presentation of data by supporting rich media.
```SQLSeal
SELECT a('https://example.com', 'Visit Example') AS link;
```
```SQLSeal
SELECT img('path/to/image.png', 'My Image') AS image;
```
--------------------------------
### SQLSeal Clustering Data Transformation
Source: https://hypersphere.blog/sql-seal/charts/clustering
This code snippet demonstrates how to transform data for clustering using SQLSeal. It prepares the data into an array format suitable for further processing and visualization.
```javascript
const datasetArray = data.map(d => ([d.x, d.y]))
var CLUSTER_COUNT = 6;
var DIENSIION_CLUSTER_INDEX = 2;
var COLOR_ALL = [
'#37A2DA',
'#e06343',
'#37a354',
'#b55dba',
'#b5bd48',
'#8378EA',
'#96BFFF'
];
var pieces = [];
for (var i = 0; i < CLUSTER_COUNT; i++) {
pieces.push({
value: i,
label: 'cluster ' + i,
color: COLOR_ALL[i]
});
}
return {
dataset: [
{
source: datasetArray,
id: 'data'
},
{
transform: {
type: 'ecStat:clustering',
print: true,
config: {
clusterCount: CLUSTER_COUNT,
outputType: 'single',
outputClusterIndexDimension: DIENSIION_CLUSTER_INDEX
}
}
}
],
tooltip: {
position: 'top'
},
visualMap: {
type: 'piecewise',
top: 'middle',
min: 0,
max: CLUSTER_COUNT,
left: 10,
splitNumber: CLUSTER_COUNT,
dimension: DIENSIION_CLUSTER_INDEX,
pieces: pieces
},
grid: {
left: 120
},
xAxis: {},
yAxis: {},
series: {
type: 'scatter',
encode: { tooltip: [0, 1] },
symbolSize: 15,
itemStyle: {
borderColor: '#555'
},
datasetIndex: 1
}
};
```
--------------------------------
### Fix parsing arguments for file function
Source: https://hypersphere.blog/sql-seal/changelog
Corrects the parsing of arguments for the `file` function, ensuring that parameters containing symbols like `[]*` (e.g., JSONPath arguments) are handled properly.
```git
Fixes:
* Fixed parsing arguments to the `file` function. Now parameters with symbols like `[]*` should work properly (i.e. JSONPath arguments)
```
--------------------------------
### Render SQL Results as HTML Table
Source: https://hypersphere.blog/sql-seal/changing-render-method
Displays SQL query results as a standard HTML table. This method is straightforward and requires no additional options.
```SQLSeal
TABLE data = file(./data.csv)
HTML
SELECT * FROM data
LIMIT 10
```
--------------------------------
### Select files associated with a specific tag
Source: https://hypersphere.blog/sql-seal/query-vault-content
Selects files that have a specific tag, '#important', by joining the 'files' and 'tags' tables on their common 'path' column.
```sql
SELECT files.* FROM files JOIN tags ON files.path=tags.path WHERE tag = '#important'
```
--------------------------------
### Create Scatter Plot with SQLSeal
Source: https://hypersphere.blog/sql-seal/charts/types/scatter-plot
Renders a scatter plot comparing book word count and rating, with interactive labels on hover. It configures the y-axis minimum to 1 and the x-axis to a log2 scale.
```sqlseal
TABLE d = table(0)
CHART {
xAxis: {
type: 'log',
logBase: '2'
},
yAxis: {
min: 1
},
tooltip: { },
series: [{
type: 'scatter',
symbolSize: 5,
encode: {
x: 'wordcount',
y: 'rating',
tooltip: 'title'
}
}]
}
SELECT * FROM d
```
--------------------------------
### Case-insensitive SQL keywords in SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.15.0 of SQLSeal improved the SQL parser to be less case-sensitive. Users can now use keywords such as `TABLE`, `HTML`, and `MARKDOWN` in any casing, making queries more flexible and user-friendly. This change enhances the accessibility of SQL queries within the plugin.
```SQLSeal
select * from my_table;
TABLE my_table;
Html my_table;
```
--------------------------------
### Add interactive checkbox field to tasks
Source: https://hypersphere.blog/sql-seal/changelog
Introduces an interactive checkbox field to the tasks table, allowing users to mark tasks as completed directly within SQLSeal.
```git
feat: added checkbox field to tasks which adds **interactive** checkbox so you can mark tasks as completed directly from the SQLSeal
```
--------------------------------
### CSV Viewer and rendering options in SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
The 0.11.0 update introduced a CSV Viewer in SQLSeal, allowing users to preview and edit CSV files directly within Obsidian. It also added different renderer methods: GRID (default), HTML (standard table), and MARKDOWN (ASCII table representation).
```SQLSeal
SELECT * FROM my_csv_file RENDER AS HTML;
```
```SQLSeal
SELECT * FROM my_csv_file RENDER AS MARKDOWN;
```
--------------------------------
### Render SQL Results as Markdown Table
Source: https://hypersphere.blog/sql-seal/changing-render-method
Renders SQL query results as a text-based Markdown table. This is useful for embedding static tables in documents or for a plain text preference. No extra options are available for this renderer.
```SQLSeal
TABLE data = file(./data.csv)
MARKDOWN
SELECT * FROM data
LIMIT 10
```
--------------------------------
### Render SQL Results using Grid View
Source: https://hypersphere.blog/sql-seal/changing-render-method
Utilizes the default Grid view renderer, powered by AG Grid, for feature-rich and visually appealing table displays. This method can be explicitly set using the GRID keyword.
```SQLSeal
TABLE data = file(./data.csv)
GRID
SELECT * FROM data
LIMIT 10
```
--------------------------------
### Add tags column to files table
Source: https://hypersphere.blog/sql-seal/changelog
Includes a `tags` column in the files table, which populates with tags defined directly in the file's properties, enhancing metadata organization.
```git
feat: files table now contains tags column with tags defined directly in properties (by @sksizer)
```
--------------------------------
### Handle numbers properly
Source: https://hypersphere.blog/sql-seal/changelog
Corrects the handling of numerical data, ensuring that numbers are processed and displayed accurately.
```git
fix: numbers are now properly handled (by @satkowski)
```
--------------------------------
### Manually define column types
Source: https://hypersphere.blog/sql-seal/changelog
Adds the functionality to manually specify data types for columns, providing greater control over data interpretation and handling.
```git
e3a24cd: added ability to manually define column types
```
--------------------------------
### Fix grid column rendering
Source: https://hypersphere.blog/sql-seal/changelog
Addresses a problem with how grid columns were rendered, ensuring they automatically adjust to content width and do not truncate text.
```git
fix: fixed how grid renders columns - now they automatically match content and don't truncate the text
```
--------------------------------
### SQL Date Formatting
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.22.0 standardizes date fields `created_at` and `modified_at` from JavaScript Unix epoch to ISO 8601 format. This simplifies date operations, such as extracting the year.
```sql
SELECT strftime("%Y", created_at) AS creation_year FROM files;
-- Before: SELECT strftime("%Y", datetime(ROUND(created_at / 1000), 'unixepoch')) FROM files;
```
--------------------------------
### Add variable editor for SQL queries
Source: https://hypersphere.blog/sql-seal/changelog
Introduces a variable editor for the SQLSealExplorer. This feature automatically displays and allows users to set values for variables used in SQL queries (prefixed with '@').
```git
ce1da3f: added variable editor to the SQLSealExplorer - now if your query uses @variables they will automatically show up below the code so you can set their values.
```
--------------------------------
### Render SQL Results as HTML Table
Source: https://hypersphere.blog/sql-seal/renderers/html
Renders the results of a SQL query into a basic HTML table. This is the default behavior for displaying query outputs.
```HTML
SELECT name, path FROM files LIMIT 10
```
--------------------------------
### SQL-Seal Basic Bar Chart
Source: https://hypersphere.blog/sql-seal/charts/types/bar-chart
Generates a basic bar chart using SQL-Seal. It specifies the chart type as 'bar' and configures the x-axis for categorical data. The query selects all data from table 't'.
```sqlseal
TABLE t = table(0)
CHART {
xAxis: {
type: 'category'
},
yAxis: {},
series: [
{
type: 'bar'
}
]
}
SELECT * FROM t
```
--------------------------------
### SQLSeal mobile compatibility with SQL.JS
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.10.0 made SQLSeal compatible with mobile devices by switching from `better-sqlite3` to `SQL.JS`. This WebAssembly-based library eliminates the need for native binaries, making the plugin portable across different platforms. The parser was also reworked from Antlr4TS to Antlr4.
```JavaScript
// Example using SQL.JS (hypothetical)
import initSqlJs from 'sql.js';
initSqlJs().then(function (SQL) {
const db = new SQL.Database();
db.run("CREATE TABLE data (col1, col2);");
db.run("INSERT INTO data VALUES (?, ?);", [1, 'test']);
const res = db.exec("SELECT * FROM data");
console.log(res);
db.close();
});
```
--------------------------------
### SQLSeal persistence with IndexedDB and WebWorker
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.12.0 involved significant architectural changes for SQLSeal. The database is now persisted in IndexedDB and utilizes a WebWorker for data loading, improving efficiency and reducing memory usage, especially for large datasets. Integration with Absurd-SQL allows SQLite to be stored in block storage.
```JavaScript
// Example of interacting with a WebWorker for database operations
const dbWorker = new Worker('db-worker.js');
dbWorker.postMessage({ type: 'QUERY', payload: 'SELECT * FROM my_table;' });
dbWorker.onmessage = (event) => {
console.log('Query result:', event.data);
};
```
--------------------------------
### Display Booleans as Checkboxes with SQLSeal
Source: https://hypersphere.blog/sql-seal/links-and-images
Renders boolean data as checkboxes in the interface using the 'checkbox' function. This is useful for visually representing true/false states in query results.
```sql
SELECT date, checkbox(excercised) FROM files WHERE date is not null
```
--------------------------------
### Register CSV/JSON views conditionally
Source: https://hypersphere.blog/sql-seal/changelog
Modifies the registration of CSV and JSON views to occur only when they do not conflict with existing plugins, preventing potential collisions.
```git
285684d: csv and json views are now only registered when not colliding with other existing plugins
```
--------------------------------
### SQL-Seal Bar Chart with Multiple Series and Legend
Source: https://hypersphere.blog/sql-seal/charts/types/bar-chart
Creates a bar chart with multiple data series (e.g., 'Walked', 'Biked') and an interactive legend using SQL-Seal. It defines the y-axis encoding for each series and enables legend display.
```sqlseal
TABLE t = table(0)
CHART {
xAxis: {
type: 'category'
},
yAxis: {},
legend: { show: true },
series: [
{
type: 'bar',
encode: { y: 'walked' },
name: 'Walked'
},
{
type: 'bar',
encode: { y: 'biked' },
name: 'Biked'
}
]
}
SELECT * FROM t
```
--------------------------------
### Advanced SQLite functionality with SQLSeal
Source: https://hypersphere.blog/sql-seal/changelog
Version 0.13.0 of SQLSeal enabled advanced SQLite functionalities due to a rewritten SQL parser. This includes support for recursive CTEs, `UNION` operations, and the `json_each` function, offering more powerful data processing capabilities within Obsidian.
```SQLSeal
SELECT json_each.value FROM json_each('["apple", "banana"]');
```