### Deno Installation Source: https://github.com/asg017/sqlite-html/blob/main/README.md Link to the Deno installation for the sqlite-html library. ```html deno.land/x/sqlite_html ``` -------------------------------- ### Install sqlite-html Package Source: https://github.com/asg017/sqlite-html/blob/main/README.md Instructions for installing the sqlite-html library using package managers for Python, Node.js, and Ruby. ```shell pip install sqlite-html ``` ```shell npm install sqlite-html ``` ```shell gem install sqlite-html ``` -------------------------------- ### Install Datasette Plugin Source: https://github.com/asg017/sqlite-html/blob/main/README.md Command to install the datasette-sqlite-html plugin for Datasette. ```shell datasette install datasette-sqlite-html ``` -------------------------------- ### Install sqlite-html NPM Package Source: https://github.com/asg017/sqlite-html/blob/main/npm/sqlite-html/README.md Installs the sqlite-html package from npm. This command should be run in your Node.js project directory. ```bash npm install sqlite-html ``` -------------------------------- ### Install and Load sqlite-html via npm in Node.js Source: https://context7.com/asg017/sqlite-html/llms.txt Details how to install the `sqlite-html` package using npm and load the extension in Node.js. It utilizes `getLoadablePath` for automatic binary resolution. ```javascript import Database from "better-sqlite3"; import { getLoadablePath } from "sqlite-html"; const db = new Database(":memory:"); db.loadExtension(getLoadablePath()); const result = db.prepare("select html_extract('
Hello World
', 'b')").get(); console.log(result); // { "html_extract('Hello World
', 'b')": "World" } ``` -------------------------------- ### Python Package Installation Source: https://context7.com/asg017/sqlite-html/llms.txt How to install and use the sqlite-html extension via the Python package, simplifying the extension loading process. ```APIDOC ## Python Package Installation Install and use sqlite-html via the Python package for simplified extension loading. ```python import sqlite3 import sqlite_html conn = sqlite3.connect(":memory:") conn.enable_load_extension(True) sqlite_html.load(conn) # Now you can use all sqlite-html functions result = conn.execute("select html_extract('Hello World
', 'b')").fetchone() print(result[0]) # "World" ``` ``` -------------------------------- ### Node.js Package Installation Source: https://context7.com/asg017/sqlite-html/llms.txt Instructions for installing and using the sqlite-html extension via npm, which handles automatic platform-specific binary resolution. ```APIDOC ## Node.js Package Installation Install and use sqlite-html via npm for automatic platform-specific binary resolution. ```javascript import Database from "better-sqlite3"; import { getLoadablePath } from "sqlite-html"; const db = new Database(":memory:"); db.loadExtension(getLoadablePath()); const result = db.prepare("select html_extract('Hello World
', 'b')").get(); console.log(result); // { "html_extract('Hello World
', 'b')": "World" } ``` ``` -------------------------------- ### Deno Module Usage Source: https://context7.com/asg017/sqlite-html/llms.txt Guide on how to import and load the sqlite-html extension in Deno, including automatic binary downloading. ```APIDOC ## Deno Module Usage Import and load sqlite-html in Deno with automatic binary downloading. ```typescript import { DB } from "https://deno.land/x/sqlite3/mod.ts"; import { getLoadablePath, entrypoint, load } from "https://deno.land/x/sqlite_html/mod.ts"; const db = new DB(":memory:"); load(db); const [result] = db.prepare("select html_extract('Hello World
', 'b')").value<[string]>()!; console.log(result); // "World" ``` ``` -------------------------------- ### Load sqlite-html Extension with Datasette Source: https://github.com/asg017/sqlite-html/blob/main/README.md Command-line argument to load the sqlite-html extension when starting Datasette. ```shell datasette data.db --load-extension ./html0 ``` -------------------------------- ### Get sqlite-html Loadable Path with better-sqlite3 Source: https://github.com/asg017/sqlite-html/blob/main/npm/sqlite-html/README.md Retrieves the file path for the sqlite-html extension, suitable for use with 'better-sqlite3'. This function automatically determines the correct path based on the installed optional dependencies and the host's OS and architecture. ```javascript import Database from "better-sqlite3"; import * as sqlite_html from "sqlite-html"; const db = new Database(":memory:"); db.loadExtension(sqlite_html.getLoadablePath()); ``` -------------------------------- ### Install and Load sqlite-html via Python Package Source: https://context7.com/asg017/sqlite-html/llms.txt Provides instructions for installing the `sqlite-html` Python package and loading the extension within a Python script. This simplifies the extension loading process. ```python import sqlite3 import sqlite_html conn = sqlite3.connect(":memory:") conn.enable_load_extension(True) sqlite_html.load(conn) # Now you can use all sqlite-html functions result = conn.execute("select html_extract('Hello World
', 'b')").fetchone() print(result[0]) # "World" ``` -------------------------------- ### Install sqlite-html Python Package Source: https://github.com/asg017/sqlite-html/blob/main/python/sqlite_html/README.md Installs the sqlite-html package using pip. This is the primary method for including the package in your Python project. ```bash pip install sqlite-html ``` -------------------------------- ### Load sqlite-html Extension in SQLite CLI Source: https://github.com/asg017/sqlite-html/blob/main/README.md Example of loading the sqlite-html extension dynamically into the SQLite command-line interface and verifying its version. ```sql .load ./html0 select html_version(); -- v0.0.1 ``` -------------------------------- ### Load sqlite-html Extension in Python Source: https://github.com/asg017/sqlite-html/blob/main/python/sqlite_html/README.md Demonstrates how to use the sqlite-html Python package to load the extension into a sqlite3 connection. It shows how to get the extension path and then load it, followed by a verification query. ```python import sqlite_html import sqlite3 conn = sqlite3.connect(':memory:') sqlite_html.load(conn) result = conn.execute('select html_version()').fetchone() print(result) # Expected output: ('v0.1.0') conn.close() ``` -------------------------------- ### Get sqlite-html Loadable Path with node-sqlite3 Source: https://github.com/asg017/sqlite-html/blob/main/npm/sqlite-html/README.md Retrieves the file path for the sqlite-html extension, compatible with 'node-sqlite3'. This path can be passed to the '.loadExtension()' method of a 'node-sqlite3' database instance. ```javascript import sqlite3 from "sqlite3"; import * as sqlite_html from "sqlite-html"; const db = new sqlite3.Database(":memory:"); db.loadExtension(sqlite_html.getLoadablePath()); ``` -------------------------------- ### Manually Load sqlite-html Extension (Python) Source: https://github.com/asg017/sqlite-html/blob/main/python/sqlite_html/README.md Shows the manual process of loading the sqlite-html extension into a sqlite3 connection. This involves enabling extension loading, getting the path, loading the extension, and then disabling extension loading for security. ```python import sqlite_html import sqlite3 conn = sqlite3.connect(':memory:') # Enable extension loading conn.enable_load_extension(True) # Load the extension using the path provided by sqlite_html extension_path = sqlite_html.loadable_html() conn.load_extension(extension_path) # Disable extension loading after use conn.enable_load_extension(False) # Verify the extension is loaded version = conn.execute('select html_version()').fetchone() print(version) # Expected output: ('v0.1.0') conn.close() ``` -------------------------------- ### Get sqlite-html Loadable Extension Path (Python) Source: https://github.com/asg017/sqlite-html/blob/main/python/sqlite_html/README.md Retrieves the file system path to the sqlite-html loadable extension using the `loadable_html()` function from the sqlite_html package. This path can be used with `sqlite3.Connection.load_extension()`. ```python import sqlite_html extension_path = sqlite_html.loadable_html() print(extension_path) # Example output: '/path/to/your/venv/lib/pythonX.Y/site-packages/sqlite_html/html0' ``` -------------------------------- ### Get sqlite-html Library Version (SQL) Source: https://github.com/asg017/sqlite-html/blob/main/docs.md The html_version function returns the version string of the sqlite-html library. It follows the convention of sqlite_version(). ```sql sqlite> select html_version(); v0.0.0 ``` -------------------------------- ### Get Debug Information with html_debug Source: https://context7.com/asg017/sqlite-html/llms.txt The html_debug function provides detailed diagnostic information about the sqlite-html extension. This includes the version, Git commit hash, build runtime environment (e.g., Go version and OS), and the build date, which is invaluable for troubleshooting and understanding the extension's build context. ```sql select html_debug(); /* Version: v0.1.3 Commit: 0cd144a880b47f4a57a5c7f8ceb96eb9dc821508 Runtime: go1.17 darwin/amd64 Date: 2021-11-17T17:06:12Z-0800 */ ``` -------------------------------- ### Query HTML Elements Source: https://github.com/asg017/sqlite-html/blob/main/docs.md Functions for querying HTML documents using CSS selectors. These include iterating over elements, extracting specific elements, getting text content, and counting matches. ```APIDOC ## Query HTML Elements ### `html_each(document, selector)` **Description**: A table function that iterates over all matching elements in a document. **Method**: N/A (Table Function) **Endpoint**: N/A **Parameters**: #### Query Parameters - **document** (TEXT) - Required - The HTML document to query. - **selector** (TEXT) - Required - The CSS selector to match elements. #### Request Body N/A ### Response #### Success Response (200) - **html** (TEXT) - The HTML of the matched element. - **text** (TEXT) - The text content of the matched element. #### Response Example ```sql select * from html_each('Hello, world!
', 'b'); -- 'world!' ``` ### `html_text(document, selector)` **Description**: Extracts the first matching element from a document using a CSS selector and returns its text representation (textContent). **Method**: N/A **Endpoint**: N/A **Parameters**: #### Query Parameters - **document** (TEXT) - Required - The HTML document to query. - **selector** (TEXT) - Required - The CSS selector to match the element. #### Request Body N/A ### Response #### Success Response (200) - **text** (TEXT) - The text content of the first matching element. #### Response Example ```sql select html_text('hello dog', 'a'); -- "dog" ``` ### `html_count(document, selector)` **Description**: Counts the number of elements matching the given CSS selector in a document. **Method**: N/A **Endpoint**: N/A **Parameters**: #### Query Parameters - **document** (TEXT) - Required - The HTML document to query. - **selector** (TEXT) - Required - The CSS selector to match elements. #### Request Body N/A ### Response #### Success Response (200) - **count** (INTEGER) - The number of matching elements. #### Response Example ```sql select html_count('
a
b
c
Hello World
', 'b')").value<[string]>()!; console.log(result); // "World" ``` -------------------------------- ### Deno Permissions for x/sqlite_html Source: https://github.com/asg017/sqlite-html/blob/main/deno/README.md This command shows the necessary Deno flags to run an application that uses the x/sqlite_html module. It requires network and filesystem permissions for downloading and caching the extension, as well as the --unstable flag for FFI operations. ```bash deno run -A --unstable| Alex | 1 |
| Brian | 2 |
| Craig | 3 |