### Run Project Tests Source: https://github.com/h-sphere/sql-seal/blob/main/docs/contributing/project-setup.md Executes the project's test suite to verify the setup. Requires Node.js and pnpm to be installed. ```bash pnpm test ``` -------------------------------- ### Install Project Dependencies with pnpm Source: https://github.com/h-sphere/sql-seal/blob/main/docs/contributing/project-setup.md Installs all necessary project dependencies using the pnpm package manager. Requires Node.js and pnpm to be installed. ```bash pnpm install ``` -------------------------------- ### Clone SQLSeal Repository Source: https://github.com/h-sphere/sql-seal/blob/main/docs/contributing/project-setup.md Clones the SQLSeal project repository from GitHub. Requires Git to be installed. ```bash git clone git@github.com:h-sphere/sql-seal.git ``` -------------------------------- ### Compile SQLSeal Project Source: https://github.com/h-sphere/sql-seal/blob/main/docs/contributing/project-setup.md Compiles the TypeScript and WASM files into a single main.js file. Requires Node.js and pnpm to be installed. Note: no watch mode available, requires manual rebuild and vault refresh. ```bash pnpm build ``` -------------------------------- ### Analyzing Data Under Different Headers Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md An example that aggregates revenue data from tables located under different quarterly headers (Q1 Results, Q2 Results, etc.) using UNION ALL. ```sqlseal 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 ``` -------------------------------- ### Joining Data from Different Files Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md An example of joining sales data from one file with target data from another file based on the 'Month' column. ```sqlseal 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 ``` -------------------------------- ### Link SQLSeal into Obsidian Vault Source: https://github.com/h-sphere/sql-seal/blob/main/docs/contributing/project-setup.md Creates a symbolic link to integrate the cloned SQLSeal project into an Obsidian vault's plugins folder for development. This allows for easier testing of changes. ```bash ln -s ../cloned-location sqlseal ``` -------------------------------- ### SQLSeal Query Configuration Example Source: https://github.com/h-sphere/sql-seal/blob/main/docs/query-configuration.md Demonstrates the basic structure of a SQLSeal query configuration, including TABLE statements, REFRESH, EXPLAIN, GRID, and SELECT clauses. ```sqlseal TABLE data = file(data.csv) REFRESH EXPLAIN GRID SELECT * FROM data ``` -------------------------------- ### SQL-Seal Inline Query Examples Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md Demonstrates how to embed SQL-Seal queries directly within text to display aggregated results. These inline queries rely on pre-defined table structures elsewhere in the document. ```sql S> SELECT SUM(Revenue) FROM sales ``` ```sql S> SELECT ROUND(AVG(Amount), 2) FROM transactions ``` -------------------------------- ### Install SQLSeal Types Package Source: https://github.com/h-sphere/sql-seal/blob/main/types-package/README.md Installs the @hypersphere/sqlseal package as a dev dependency using npm. ```bash npm install --save-dev @hypersphere/sqlseal ``` -------------------------------- ### Advanced SQLSeal Example with External Data Source: https://github.com/h-sphere/sql-seal/blob/main/docs/links-and-images.md An advanced example integrating with a Kaggle dataset (Goodreads-books) loaded via CSV. It displays book titles with Open Library links and cover images, filtering by author using an Obsidian property. Includes type casting for ISBN. ```sqlseal 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 ``` -------------------------------- ### Create Doughnut Chart - SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/types/pie-chart.md This example demonstrates how to create a doughnut (ring style) chart by specifying inner and outer radii for the pie series. It uses data from the 'finances' table. ```sqlseal TABLE finances = table(0) CHART { series: [{ type: 'pie', radius: ['40%', '70%'] }] } SELECT * FROM finances ``` -------------------------------- ### Frontmatter Tags Example in YAML Source: https://github.com/h-sphere/sql-seal/blob/main/docs/faq/understanding-tags.md Demonstrates how to declare tags within the YAML frontmatter of an Obsidian file using a list format. This is a common way to associate metadata with a file. ```yaml --- tags: [project, todo] --- ``` -------------------------------- ### File Path Options for Referencing Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md Illustrates different path options for referencing files, including absolute paths, relative paths, and using optional file extensions. ```sqlseal -- Absolute Paths TABLE data = table(file:Finance/reports/q1.md, 0) -- Relative Paths -- Same folder, reports subfolder TABLE data = table(file:./reports/q1.md, 0) -- Parent folder TABLE summary = table(file:../summary.md, 0) -- Optional Extension TABLE data = table(file:Finance/reports/q1, 0) -- Will look for q1.md ``` -------------------------------- ### SQLSeal Comments Example Source: https://github.com/h-sphere/sql-seal/blob/main/docs/comments.md Demonstrates the use of single-line and block comments in SQLSeal. Single-line comments start with '--' and extend to the end of the line. Block comments are enclosed by '/*' and '*/', allowing for multi-line comments or disabling larger code sections. ```sqlseal TABLE a = file(file.csv) -- TABLE b = file(file2.csv) /* GRID NO REFRESH */ SELECT * FROM a -- WHERE value > 5 ``` -------------------------------- ### Create Nightingale Chart - SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/types/pie-chart.md This snippet illustrates how to generate a Nightingale (Rose) chart by setting the `roseType` to 'area'. The chart visualizes data from the 'finances' table. ```sqlseal TABLE finances = table(0) CHART { series: [{ type: 'pie', roseType: 'area' }] } SELECT * FROM finances ``` -------------------------------- ### Reference Table from Another File by Index Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md Accesses a markdown table from a different file using the 'file:' prefix followed by the file path and table index. ```sqlseal TABLE expenses = table(file:Finance/expenses.md, 0) ``` -------------------------------- ### Check SQLSeal Version (TypeScript) Source: https://github.com/h-sphere/sql-seal/blob/main/types-package/README.md Shows how to retrieve the currently installed SQLSeal version using the plugin API. ```typescript const api = pluginApi('sqlseal') as SQLSealRegisterApi console.log(api.sqlSealVersion) // i.e. '0.20.0' ``` -------------------------------- ### Reference Multiple Tables from Another File by Header and Index Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md Demonstrates referencing specific tables from another file when multiple tables exist under the same header, using the parent header and index. ```sqlseal TABLE revenue = table(file:Finance/annual-report.md, Financial Data, 0) TABLE expenses = table(file:Finance/annual-report.md, Financial Data, 1) ``` -------------------------------- ### SQLSeal Query Example using CSV Source: https://github.com/h-sphere/sql-seal/blob/main/docs/quick-start.md This snippet demonstrates how to query a CSV file using SQLSeal within Obsidian. It defines a table named 'transactions' based on a 'transactions.csv' file and then performs a SQL SELECT query to retrieve specific columns. ```sqlseal TABLE transactions = file(transactions.csv) SELECT name, value FROM transactions ``` -------------------------------- ### Reference Table from Another File by Header Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md Combines file referencing with header referencing to access a specific table within another markdown file. ```sqlseal TABLE summary = table(file:Finance/annual-report.md, Revenue Summary) ``` -------------------------------- ### Reference Multiple Tables Under Same Header Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md Demonstrates referencing specific tables when multiple tables exist under the same header, either by subheader name or by parent header and index. ```sqlseal -- 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 ``` -------------------------------- ### Get All Files from Vault Source: https://github.com/h-sphere/sql-seal/blob/main/docs/query-vault-content.md Retrieves all files from the vault using the `files` table. This query provides a basic overview of all available file entries. ```sqlseal SELECT * FROM files ``` -------------------------------- ### Reference Table by Header Name Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md References a markdown table by the header it follows. This makes queries more resilient to document changes compared to index-based referencing. The reference is case-insensitive. ```sqlseal TABLE expenses = table(Monthly Expenses) ``` -------------------------------- ### Reference Table by Index Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md References a markdown table using its numeric index within the document. This method is simple but can be fragile if the document structure changes. ```sqlseal TABLE expenses = table(0) SELECT * FROM expenses ``` -------------------------------- ### Customize Grid View with Default Column Behavior in SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/changing-render-method.md Customizes the default behavior for all columns in the Grid view using AG Grid's configuration. This example sets text filtering and column stretching. ```sqlseal TABLE data = file(./data.csv) GRID { defaultColDef: { filter: "agTextColumnFilter", flex: 1 } } SELECT * FROM data LIMIT 100 ``` -------------------------------- ### SQL Seal Query with Rounded Results Source: https://github.com/h-sphere/sql-seal/blob/main/docs/query-markdown-tables.md Shows how to query a markdown table, alias it, and calculate a rounded sum. This example is intended for use within SQL Seal and processes data from a markdown table. ```sqlseal TABLE expenses = table(0) SELECT date, ROUND(SUM(Amount), 2) as Spent FROM expenses GROUP BY date ``` -------------------------------- ### SQL-Seal Expense Summary Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/markdown-tables.md Generates a monthly expense summary categorized by spending. It uses the strftime function for date formatting and ROUND for currency precision. Assumes a table named 'expenses' with 'Date', 'Category', and 'Amount' columns. ```sqlseal TABLE expenses = table(0) HTML 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 ``` -------------------------------- ### Multi-Series Bar Chart with Legend in SQL-Seal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/types/bar-chart.md This example illustrates how to create a bar chart with multiple series in SQL-Seal, including an interactive legend. It specifies two series, 'walked' and 'biked', mapping their respective columns to the y-axis and assigning names. The legend is enabled using `legend: { show: true }`. ```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 ``` -------------------------------- ### Query Links in Specific Frontmatter Property (SQL) Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/vault-data.md This SQL query demonstrates how to select links that are associated with a specific frontmatter property, named 'type' in this example. It's useful for analyzing relationships defined in structured metadata, such as linking notes to a 'Map of Content' (MOC). ```sql LIST SELECT a(path) FROM links WHERE target = @path AND json_extract(position, '$.frontmatterKey') = 'type' ``` -------------------------------- ### Query Nested JSON Data with JSONPath in SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/json-and-json5.md This example shows how to query data from a nested array within a JSON5 file using SQLSeal and JSONPath. The `$.results.latest[*]` JSONPath expression selects the array of objects under the 'latest' key within the 'results' object. The subsequent SQL query selects specific fields from the aliased data. ```JSON5 { results: { latest: [ { id: 1, value: 155 }, { id: 2, value: 434 }, { id: 3, value: 234 }, { id: 4, value: 54234 }, { id: 5, value: 432 }, ] } } ``` ```SQLSeal TABLE data = file(data.json5, $.results.latest[*]) SELECT id, value FROM data ``` -------------------------------- ### Create Pie Chart with Markdown Data Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/basics.md This snippet demonstrates how to create a pie chart in SQL-Seal. It first defines a table named 'finances' by reading data from the first markdown table in the file. Then, it configures a chart with a single 'pie' series and selects all data from the 'finances' table to be visualized. ```sql-seal TABLE finances = table(0) CHART { series: [{ type: 'pie' }] } SELECT * FROM finances ``` -------------------------------- ### Render Links using SQLSeal's a() function Source: https://github.com/h-sphere/sql-seal/blob/main/docs/links-and-images.md Demonstrates how to use the `a()` SQL function to render links from a 'path' column. An optional second parameter can be used to specify the link's display name. ```sqlseal SELECT a(path) FROM files LIMIT 10 ``` ```sqlseal SELECT a(path, name) from files LIMIT 10 ``` -------------------------------- ### Query CSV Files with SQL in Obsidian Source: https://github.com/h-sphere/sql-seal/blob/main/README.md Demonstrates how to create a table from a CSV file using SQLSeal and then query it. The table is defined by referencing the CSV file, and subsequent SELECT statements can be used to retrieve data. Tables are currently local to the note. ```sql TABLE transactions = file(transactions.csv) SELECT * FROM transactions LIMIT 10 ``` -------------------------------- ### Create Changeset using pnpm Source: https://github.com/h-sphere/sql-seal/blob/main/CONTRIBUTING.md Command to generate a changeset file for tracking code modifications. This process helps manage versioning and releases according to semantic versioning principles. ```bash pnpm exec changeset ``` -------------------------------- ### Render Data with Handlebars Template - SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/renderers/template.md Demonstrates rendering query results using a Handlebars template. The template accesses the 'properties.path' and iterates through the 'data' array, displaying each item's 'path'. ```sqlseal TEMPLATE Current Path: {{properties.path}} {{#each data}}
{{path}}
{{/each}} SELECT * FROM files LIMIT 10 ``` -------------------------------- ### Render SQL results as a list using LIST Source: https://github.com/h-sphere/sql-seal/blob/main/docs/renderers/list.md Renders the results of a SQL query as an HTML unordered list (ul/li). Each row becomes a nested list. No default styling is applied. ```sqlseal LIST SELECT name, path FROM files LIMIT 10 ``` -------------------------------- ### Basic SQL Seal Table Query Source: https://github.com/h-sphere/sql-seal/blob/main/docs/query-markdown-tables.md Demonstrates referencing the first table in the current note and performing a group by aggregation. It requires SQL Seal syntax and operates on markdown tables. ```sqlseal TABLE expenses = table(0) SELECT date, SUM(Amount) as Total FROM expenses GROUP BY date ``` -------------------------------- ### Link to JSON File in SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/json-and-json5.md This code snippet demonstrates how to link a JSON or JSON5 file as a data source in SQLSeal. The `file()` function takes the file path and an optional JSONPath argument to specify the data location within the file. The result must be an array of objects. ```SQLSeal TABLE data = file(path.json, $.results[*]) ``` -------------------------------- ### Select Tags for Current File using @path Source: https://github.com/h-sphere/sql-seal/blob/main/docs/using-properties.md This SQL-Seal query retrieves all tags associated with the current file by matching the 'path' column in the 'tags' table with the built-in '@path' property. ```sqlseal SELECT * FROM tags WHERE path = @path ``` -------------------------------- ### Filter Files by Property (Frontmatter) Source: https://github.com/h-sphere/sql-seal/blob/main/docs/query-vault-content.md Filters files based on a specific frontmatter property using the `WHERE` clause. SQLSeal automatically creates columns for properties, allowing direct querying. ```sqlseal SELECT * FROM files WHERE type = 'resource' ``` -------------------------------- ### Register Plugin with SQLSeal (TypeScript) Source: https://github.com/h-sphere/sql-seal/blob/main/types-package/README.md Demonstrates how to register an Obsidian plugin with SQLSeal using the plugin API. It imports necessary types and registers a custom view. ```typescript import { Plugin } from 'obsidian'; import { ChartRenderer } from './chartRenderer'; import { pluginApi } from '@vanakat/plugin-api'; import type { SQLSealRegisterApi } from '@hypersphere/sqlseal' export default class SQLSealCharts extends Plugin { async onload() { this.registerWithSQLSeal(); } private registerWithSQLSeal() { const api = pluginApi('sqlseal') as SQLSealRegisterApi const registar = api.registerForPlugin(this) registar.registerView('sqlseal-charts', new ChartRenderer(this.app)) } } ``` -------------------------------- ### SQL-Seal Clustering with ECharts Visualization Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/clustering.md This snippet demonstrates how to cluster data using SQL-Seal's 'ecStat:clustering' transform. It prepares the data, defines cluster parameters, and configures an ECharts scatter plot to visualize the clustered data. The output includes setting up visual mapping based on cluster index for distinct color representation. ```javascript TABLE clustering = table(0) ADVANCED MODE CHART 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 } }; SELECT * FROM clustering ``` -------------------------------- ### Display Results as HTML Table in SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/changing-render-method.md Renders query results in a standard HTML table format. This method is straightforward and does not require additional configuration options. ```sqlseal TABLE data = file(./data.csv) HTML SELECT * FROM data LIMIT 10 ``` -------------------------------- ### Display Boolean Data as Checkboxes with SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/links-and-images.md Illustrates using the `checkbox()` SQL function to display boolean data as checkboxes. It also covers the recommended method of using a direct `checkbox` column for interactive tasks. ```sqlseal SELECT date, checkbox(excercised) FROM files WHERE date is not null ``` ```sqlseal SELECT checkbox, task FROM tasks ``` ```sqlseal SELECT task, checkbox(completed) FROM tasks ``` -------------------------------- ### Embed Images using SQLSeal's img() function Source: https://github.com/h-sphere/sql-seal/blob/main/docs/links-and-images.md Shows how to embed images in query results using the `img()` function. It covers embedding external images and local images by providing the original note's path as a second argument. ```sqlseal SELECT name, img(coverImg) FROM files ``` ```sqlseal SELECT path, img(cover, path) FROM files ``` -------------------------------- ### Display Results as Markdown Table in SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/changing-render-method.md Renders query results as a text-based Markdown table, suitable for static documents or plain text environments. This method also has no extra configuration options. ```sqlseal TABLE data = file(./data.csv) MARKDOWN SELECT * FROM data LIMIT 10 ``` -------------------------------- ### Check SQLSeal API Version Compatibility (TypeScript) Source: https://github.com/h-sphere/sql-seal/blob/main/types-package/README.md Demonstrates how to check the SQLSeal API version for compatibility. If the API version is less than 2, it logs an incompatibility message. ```typescript const api = pluginApi('sqlseal') as SQLSealRegisterApi if (api.apiVersion >= 2) { // Targetting API 2+ } else { console.log("Plugin is incompatible with SQLSeal installed. Please update SQLSeal to the latest version and try again") } ``` -------------------------------- ### SQLSeal: Mixed Bar and Line Charts with Crosshair Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/types/mixed-charts.md This SQLSeal code creates a mixed chart displaying temperature as a line graph and rainfall as a bar chart. It configures two Y-axes for different units (°C and mm) and enables an interactive crosshair for detailed data inspection. The chart is plotted using data from a table, selecting month, maximum temperature, and rainfall. ```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 ``` -------------------------------- ### Basic Scatter Plot with Interactive Tooltip (SQLSeal) Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/types/scatter-plot.md Renders a scatter plot comparing book word count and rating. It includes interactive tooltips on hover to display book titles and sets 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 ``` -------------------------------- ### Render SQL Results as HTML Table Source: https://github.com/h-sphere/sql-seal/blob/main/docs/renderers/html.md Renders the results of a SQL query into a simple HTML table. This is useful for displaying data in a web-friendly format. The basic syntax is `HTML SELECT ...`. ```sqlseal HTML SELECT name, path FROM files LIMIT 10 ``` -------------------------------- ### Display column names in list results Source: https://github.com/h-sphere/sql-seal/blob/main/docs/renderers/list.md Enables the display of column names for each item in the rendered list by applying the '.show-column-names' class. ```sqlseal LIST .show-column-names SELECT name, path FROM Files ``` -------------------------------- ### Select Current File from Files Table using @path Source: https://github.com/h-sphere/sql-seal/blob/main/docs/using-properties.md This SQL-Seal query selects all records from the 'files' table where the 'path' column matches the current file's path, using the built-in '@path' property. ```sqlseal SELECT * FROM files WHERE path = @path ``` -------------------------------- ### Filter Files by Tag using JOIN Source: https://github.com/h-sphere/sql-seal/blob/main/docs/query-vault-content.md Selects files that are associated with a specific tag by joining the `files` and `tags` tables on the `path` column. This allows for tag-based filtering of vault content. ```sqlseal SELECT files.* FROM files JOIN tags ON files.path=tags.path WHERE tag = '#important' ``` -------------------------------- ### SQLSeal: Count Files Source: https://github.com/h-sphere/sql-seal/blob/main/docs/inline-codeblocks.md Executes a SQL query to count the total number of files within the vault. This functionality requires the SQLSeal environment to be set up and accessible. ```SQLSeal S> SELECT COUNT(*) FROM files ``` -------------------------------- ### Compute Exponential Regression using SQLSeal Charts Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/regression.md This snippet demonstrates how to compute an exponential regression using SQLSeal Charts. It maps data to an array, applies the ecStat:regression transform with an exponential method, and configures chart options for scatter and line series. The output is a chart visualizing the regression. ```sqlseal TABLE regression = table(0) ADVANCED MODE CHART const dataArray = data.map(d => ([d.x, d.y])) return { dataset: [ { id: 'data', source: dataArray }, { transform: { type: 'ecStat:regression', config: { method: 'exponential' // 'end' by default // formulaOn: 'start' } } } ], title: { text: '1981 - 1998 gross domestic product GDP (trillion yuan)', subtext: 'By ecStat.regression', sublink: 'https://github.com/ecomfe/echarts-stat', left: 'center' }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross' } }, xAxis: { splitLine: { lineStyle: { type: 'dashed' } } }, yAxis: { splitLine: { lineStyle: { type: 'dashed' } } }, series: [ { name: 'scatter', type: 'scatter', datasetIndex: 0 }, { name: 'line', type: 'line', smooth: true, datasetIndex: 1, symbolSize: 0.1, symbol: 'circle', label: { show: true, fontSize: 16 }, labelLayout: { dx: -20 }, encode: { label: 2, tooltip: 1 } } ] } SELECT * FROM regression ``` -------------------------------- ### Query Recent Files in Obsidian Source: https://github.com/h-sphere/sql-seal/blob/main/docs/index.md This SQL query retrieves all columns from the 'files' table, sorts the results by modification date in descending order, and limits the output to the 10 most recently modified files. ```sqlseal SELECT * FROM files ORDER BY modified_at DESC LIMIT 10 ``` -------------------------------- ### Basic Bar Chart in SQL-Seal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/types/bar-chart.md This code snippet demonstrates the basic syntax for creating a bar chart in SQL-Seal. It sets the x-axis to be categorical and defines a single series of type 'bar'. The data is selected from a table named 't'. ```sqlseal TABLE t = table(0) CHART { xAxis: { type: 'category' }, yAxis: {}, series: [ { type: 'bar' } ] } SELECT * FROM t ``` -------------------------------- ### Analyze Commute Data with SQL Source: https://github.com/h-sphere/sql-seal/blob/main/docs/index.md This SQL query analyzes commute data from a CSV file named 'transport.csv'. It calculates the total distance and concatenates purposes for each date and transport type, filtered by a specific date. ```sqlseal TABLE commute = file(transport.csv) SELECT Date, transport_type, SUM(distance_km) AS total_distance, group_concat(purpose) as purposes FROM commute WHERE date = @date GROUP BY Date, Transport_Type ``` -------------------------------- ### Style specific list columns using data attributes Source: https://github.com/h-sphere/sql-seal/blob/main/docs/renderers/list.md Allows styling of individual list elements based on their column name. The column name is accessible via the 'data-sqlseal-column' attribute. ```css .sqlseal-list-element-single[data-sqlseal-column="name"] { background: red; } ``` -------------------------------- ### Use Default Grid View in SQLSeal Source: https://github.com/h-sphere/sql-seal/blob/main/docs/changing-render-method.md Explicitly uses the default Grid view renderer, which internally uses AG Grid. This view is feature-rich for displaying tabular data. ```sqlseal TABLE data = file(./data.csv) GRID SELECT * FROM data LIMIT 10 ``` -------------------------------- ### SQL Seal Inline Query for Single Value Source: https://github.com/h-sphere/sql-seal/blob/main/docs/query-markdown-tables.md Illustrates embedding a single aggregated value directly into markdown text using an inline SQL Seal query. This is useful for quick data display within notes. ```sqlseal S> SELECT ROUND(SUM(amount), 2) FROM expenses ``` -------------------------------- ### Query Links in Note Body (SQL) Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/vault-data.md This SQL query retrieves all links from the 'links' table where the target is the current path and the link does not appear within a frontmatter property. It's useful for identifying direct references within the main content of notes. ```sql SELECT * FROM links WHERE target = @path AND json_extract(position, '$.frontmatterKey') IS NULL ``` -------------------------------- ### SQL-Seal Radar Chart Configuration Source: https://github.com/h-sphere/sql-seal/blob/main/docs/charts/types/radar.md Configures a radar chart using SQL-Seal. It defines the data source, chart type, indicators (axes) with their maximum values, shape, splitting numbers, and series appearance. The query selects all data from the input table. ```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 ``` -------------------------------- ### Apply custom CSS classes to list elements Source: https://github.com/h-sphere/sql-seal/blob/main/docs/renderers/list.md Applies custom CSS classes to the parent element of the list for styling purposes. Multiple classes can be applied by concatenating them with a dot. ```sqlseal LIST .my-custom-class SELECT name, path FROM files LIMIT 10 ``` ```sqlseal LIST .my-custom-class.another-class SELECT name, path FROM files LIMIT 10 ``` -------------------------------- ### Query Last 10 Modified Files in Vault Source: https://github.com/h-sphere/sql-seal/blob/main/docs/data-sources/vault-data.md Fetches the last 10 files modified in the vault. This query utilizes the 'files' table, which is automatically populated by SQLSeal and updates on file changes. It orders the results by the 'modified_at' timestamp in descending order. ```sqlseal SELECT * FROM files ORDER BY modified_at DESC LIMIT 10 ``` -------------------------------- ### Apply Custom CSS Class to HTML Table Source: https://github.com/h-sphere/sql-seal/blob/main/docs/renderers/html.md Applies a custom CSS class to the HTML table generated from a SQL query. This allows for custom styling of the table using CSS. Multiple classes can be applied by chaining them with dots. ```sqlseal HTML .my-custom-class SELECT name, path FROM files LIMIT 10 ``` ```sqlseal HTML .my-custom-class.another-class SELECT name, path FROM files LIMIT 10 ``` -------------------------------- ### SQLSeal: Count Distinct Tags Source: https://github.com/h-sphere/sql-seal/blob/main/docs/inline-codeblocks.md Calculates the number of unique tags present in the vault using a SQL query. This is useful for understanding the variety of tags used. ```SQLSeal S> SELECT COUNT(DISTINCT tag) FROM tags ``` -------------------------------- ### SQLSeal: Count Completed Tasks Source: https://github.com/h-sphere/sql-seal/blob/main/docs/inline-codeblocks.md Counts the number of tasks marked as completed within the vault. The query filters tasks where the 'completed' field is set to 1. ```SQLSeal S> SELECT COUNT(*) FROM tasks WHERE completed=1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.