### Install datasette-sqlite-url plugin (Datasette) Source: https://github.com/asg017/sqlite-url/blob/main/README.md Installs the datasette-sqlite-url plugin for Datasette. This allows Datasette to use the sqlite-url functionality. ```bash datasette install datasette-sqlite-url ``` -------------------------------- ### Install sqlite-url Python Package Source: https://github.com/asg017/sqlite-url/blob/main/python/sqlite_url/README.md Installs the sqlite-url package using pip. This is the recommended way to install the package for use in Python applications. ```bash pip install sqlite-url ``` -------------------------------- ### Install sqlite-url NPM Package Source: https://github.com/asg017/sqlite-url/blob/main/npm/sqlite-url/README.md Installs the sqlite-url package using npm. This command is used by Node.js developers to add the package to their project dependencies. ```bash npm install sqlite-url ``` -------------------------------- ### Get Loadable Path for better-sqlite3 Source: https://github.com/asg017/sqlite-url/blob/main/npm/sqlite-url/README.md Example of using getLoadablePath() to obtain the path for loading the sqlite-url extension with better-sqlite3. This snippet demonstrates the direct usage of the function within a Node.js script. ```javascript import Database from "better-sqlite3"; import * as sqlite_url from "sqlite-url"; const db = new Database(":memory:"); db.loadExtension(sqlite_url.getLoadablePath()); ``` -------------------------------- ### Install sqlite-url with gem (Ruby) Source: https://github.com/asg017/sqlite-url/blob/main/README.md Installs the sqlite-url gem for Ruby. This is the standard way to manage Ruby packages. ```bash gem install sqlite-url ``` -------------------------------- ### Load sqlite-url Extension via SQLite CLI Source: https://context7.com/asg017/sqlite-url/llms.txt This example shows how to load the sqlite-url extension when using the SQLite command-line interface. The `.load` command is used to specify the path to the extension file. ```sql .load ./url0 SELECT url_version(); -- v0.1.0 ``` -------------------------------- ### Load sqlite-url extension with Datasette Source: https://github.com/asg017/sqlite-url/blob/main/README.md Command to start Datasette and load the sqlite-url extension. This makes the extension's functions available within Datasette. ```bash datasette data.db --load-extension ./url0 ``` -------------------------------- ### Get sqlite-url Loadable Extension Path Source: https://github.com/asg017/sqlite-url/blob/main/python/sqlite_url/README.md Retrieves the full path to the locally installed sqlite-url extension. This path can be used with sqlite3.Connection.load_extension(). ```python import sqlite_url print(sqlite_url.loadable_url()) # '/.../venv/lib/python3.9/site-packages/sqlite_url/url0' ``` -------------------------------- ### Get Loadable Path for node-sqlite3 Source: https://github.com/asg017/sqlite-url/blob/main/npm/sqlite-url/README.md Illustrates how to use getLoadablePath() to get the extension path for node-sqlite3. This code snippet shows the integration of the function with the node-sqlite3 library's database object. ```javascript import sqlite3 from "sqlite3"; import * as sqlite_url from "sqlite-url"; const db = new sqlite3.Database(":memory:"); db.loadExtension(sqlite_url.getLoadablePath()); ``` -------------------------------- ### Load sqlite-url Extension in Node.js Source: https://context7.com/asg017/sqlite-url/llms.txt This Node.js example shows how to load the sqlite-url extension using the `better-sqlite3` library. It utilizes `getLoadablePath` to specify the extension's location before executing SQL queries. ```javascript import Database from 'better-sqlite3'; import { getLoadablePath } from 'sqlite-url'; const db = new Database(':memory:'); db.loadExtension(getLoadablePath()); // Use the extension const result = db.prepare("SELECT url_scheme('https://example.com')").get(); console.log(result); // { 'url_scheme(...)': 'https' } ``` -------------------------------- ### Load sqlite-url extension in Node.js Source: https://github.com/asg017/sqlite-url/blob/main/README.md Demonstrates loading the sqlite-url extension in Node.js using the better-sqlite3 library. It loads the 'url0' extension and then executes a query to get the version. ```javascript const Database = require("better-sqlite3"); const db = new Database(":memory:"); db.loadExtension("./url0"); console.log(db.prepare("select url_version()").get()); // { 'html_version()': 'v0.0.1' } ``` -------------------------------- ### Python API - loadable_url() Source: https://github.com/asg017/sqlite-url/blob/main/python/sqlite_url/README.md The `loadable_url()` function returns the full path to the locally installed `sqlite-url` extension. This path can be used with `sqlite3.Connection.load_extension()`, though `sqlite_url.load()` is the preferred method. ```APIDOC ## Python API - loadable_url() ### Description Returns the full path to the locally-install `sqlite-url` extension, without the filename. This can be directly passed to [`sqlite3.Connection.load_extension()`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.load_extension), but the [`sqlite_url.load()`](#load) function is preferred. ### Method ```python sqlite_url.loadable_url() ``` ### Parameters None ### Request Example ```python import sqlite_url print(sqlite_url.loadable_url()) # '/.../venv/lib/python3.9/site-packages/sqlite_url/url0' ``` ### Response #### Success Response - **path** (string) - The absolute path to the loadable extension file (without extension). #### Response Example ```json { "path": "/.../venv/lib/python3.9/site-packages/sqlite_url/url0" } ``` > Note: this extension path doesn't include the file extension (`.dylib`, `.so`, `.dll`). This is because [SQLite will infer the correct extension](https://www.sqlite.org/loadext.html#loading_an_extension). ``` -------------------------------- ### Get Library Version Source: https://context7.com/asg017/sqlite-url/llms.txt Retrieves the version string of the sqlite-url library. This is useful for verifying the extension is loaded and checking compatibility. ```APIDOC ## GET /url_version ### Description Returns the version string of the sqlite-url library. ### Method GET ### Endpoint /url_version ### Parameters None ### Request Example ```sql SELECT url_version(); ``` ### Response #### Success Response (200) - **version** (string) - The version string of the sqlite-url library. #### Response Example ```json { "version": "v0.1.0" } ``` ``` -------------------------------- ### Get Debug Information Source: https://context7.com/asg017/sqlite-url/llms.txt Returns detailed debug information about the sqlite-url library, including version, build date, source, and libcurl version. ```APIDOC ## GET /url_debug ### Description Returns debug information about the sqlite-url library. ### Method GET ### Endpoint /url_debug ### Parameters None ### Request Example ```sql SELECT url_debug(); ``` ### Response #### Success Response (200) - **debug_info** (string) - A multi-line string containing debug information. #### Response Example ```json { "debug_info": "Version: v0.1.0\nDate: 2022-...\nSource: ...\nlibcurl: libcurl/7.84.0" } ``` ``` -------------------------------- ### Get sqlite-url library version Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Retrieves the version string of the sqlite-url library. This function takes no arguments and returns a string representing the library's version. ```sql select url_version(); ``` -------------------------------- ### Get sqlite-url Library Version Source: https://context7.com/asg017/sqlite-url/llms.txt Retrieves the version string of the sqlite-url library. This is useful for confirming the extension is loaded and checking compatibility. ```sql SELECT url_version(); -- Result: 'v0.1.0' ``` -------------------------------- ### Get sqlite-url Library Debug Information Source: https://context7.com/asg017/sqlite-url/llms.txt Fetches detailed debug information about the sqlite-url library, including its version, build date, source, and the version of libcurl used. This helps in diagnosing issues and understanding the environment. ```sql SELECT url_debug(); -- Result: 'Version: v0.1.0 -- Date: 2022-... -- Source: ... -- libcurl: libcurl/7.84.0' ``` -------------------------------- ### Load sqlite-url Extension with better-sqlite3 Source: https://github.com/asg017/sqlite-url/blob/main/npm/sqlite-url/README.md Demonstrates how to load the sqlite-url extension into a better-sqlite3 database instance. It imports the necessary libraries, creates an in-memory database, loads the extension using getLoadablePath(), and then queries the extension version. ```javascript import Database from "better-sqlite3"; import * as sqlite_url from "sqlite-url"; const db = new Database(":memory:"); db.loadExtension(sqlite_url.getLoadablePath()); const version = db.prepare("select url_version()").pluck().get(); console.log(version); // "v0.2.0" ``` -------------------------------- ### Generate URL Programmatically with SQL Source: https://github.com/asg017/sqlite-url/blob/main/README.md Illustrates how to construct a URL by providing its components (scheme, host, fragment) as arguments to the `url` function. ```sql select url(null, 'scheme', 'https', 'host', 'alexgarcia.url', 'fragment', 'yeet' ); -- 'https://alexgarcia.url/#yeet' ``` -------------------------------- ### Deno run command with permissions Source: https://github.com/asg017/sqlite-url/blob/main/deno/README.md This command shows how to run a Deno script that utilizes the x/sqlite_url module. It requires the --allow-all flag (or specific flags like --allow-ffi and --unstable) to grant the necessary network and filesystem permissions for downloading and caching the SQLite extension. ```bash deno run -A --unstable ``` -------------------------------- ### Safely Generate URL Path with sqlite-path and SQL Source: https://github.com/asg017/sqlite-url/blob/main/README.md Demonstrates using `sqlite-url` in conjunction with `sqlite-path`'s `path_join` function to securely construct a URL path. ```sql select url( 'https://github.com', 'path', path_join('/', 'asg017', 'sqlite-url', 'issues', '1') ); -- 'https://github.com/asg017/sqlite-url/issues/1' ``` -------------------------------- ### Determine Supported Platform Source: https://github.com/asg017/sqlite-url/blob/main/npm/sqlite-url/README.md A bash command to display the current Node.js process's platform and architecture. This helps users identify if their system is supported by the sqlite-url NPM package. ```bash $ node -e 'console.log([process.platform, process.arch])' [ 'darwin', 'x64' ] ``` -------------------------------- ### Load sqlite-url Extension with node-sqlite3 Source: https://github.com/asg017/sqlite-url/blob/main/npm/sqlite-url/README.md Shows how to load the sqlite-url extension with the node-sqlite3 library. It involves importing sqlite3 and sqlite-url, creating a database instance, loading the extension, and then executing a query asynchronously. ```javascript import sqlite3 from "sqlite3"; import * as sqlite_url from "sqlite-url"; const db = new sqlite3.Database(":memory:"); db.loadExtension(sqlite_url.getLoadablePath()); db.get("select url_version()", (err, row) => { console.log(row); // {json_schema_version(): "v0.2.0"} }); ``` -------------------------------- ### Load and Validate URL with SQL Source: https://github.com/asg017/sqlite-url/blob/main/README.md Demonstrates how to load the sqlite-url extension and use the `url_valid` function to check if a given string is a valid URL. ```sql .load ./url0 select url_valid('https://sqlite.org'); -- 1 ``` -------------------------------- ### Iterate Through URL Query Parameters with SQL Source: https://github.com/asg017/sqlite-url/blob/main/README.md Demonstrates how to parse a URL's query string and iterate through its key-value pairs using `url_query` and `url_query_each` functions. ```sql select * from url_query_each( url_query('https://api.census.gov/data/2020/acs/acs5?get=B01001_001E&for=county:*&in=state:06') ); /* ┌──────┬─────────────┐ │ name │ value │ ├──────┼─────────────┤ │ get │ B01001_001E │ │ for │ county:* │ │ in │ state:06 │ └──────┴─────────────┘ */ ``` -------------------------------- ### Load sqlite-url extension in SQLite CLI Source: https://github.com/asg017/sqlite-url/blob/main/README.md Demonstrates how to load the sqlite-url extension (.load ./url0) and call the url_version() function using the SQLite command-line interface. ```sql .load ./url0 select url_version(); -- v0.0.1 ``` -------------------------------- ### Extract URL Components with SQL Source: https://github.com/asg017/sqlite-url/blob/main/README.md Shows how to extract specific parts of a URL, such as the scheme, host, path, and fragment, using dedicated SQL functions. ```sql select url_scheme('https://www.sqlite.org/vtab.html#usage'); -- 'https' select url_host('https://www.sqlite.org/vtab.html#usage'); -- 'www.sqlite.org' select url_path('https://www.sqlite.org/vtab.html#usage'); -- '/vtab.html' select url_fragment('https://www.sqlite.org/vtab.html#usage'); -- 'usage' ``` -------------------------------- ### Load sqlite-url extension in Deno Source: https://github.com/asg017/sqlite-url/blob/main/deno/README.md This snippet demonstrates how to import and load the sqlite-url extension within a Deno application using the x/sqlite3 module. It initializes an in-memory database, enables extension loading, loads the sqlite_url extension using its path, and then queries the extension's version. ```javascript import { Database } from "https://deno.land/x/sqlite3@0.8.0/mod.ts"; import * as sqlite_url from "https://deno.land/x/sqlite_url@v0.1.0/mod.ts"; const db = new Database(":memory:"); db.enableLoadExtension = true; db.loadExtension(sqlite_url.getLoadablePath()); const [version] = db .prepare("select url_version()") .value<[string]>()!; console.log(version); ``` -------------------------------- ### Generate a URL with specified components Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Constructs a URL by parsing a base URL and optionally overwriting its components (scheme, host, path, query, fragment, user, password, options, zoneid). If the base URL is null or empty, only the provided parameters are used. ```sql select url( 'http://github.com', 'path', 'asg017/sqlite-url', 'fragment', 'usage' ); ``` ```sql select url( '', 'scheme', 'https', 'host', 'github.com', 'path', 'asg017/sqlite-url' ); ``` -------------------------------- ### Load sqlite-url Extension with Explicit Enable/Disable Source: https://github.com/asg017/sqlite-url/blob/main/python/sqlite_url/README.md Loads the sqlite-url extension into an SQLite connection after explicitly enabling and then disabling extension loading. This demonstrates a more explicit control flow for loading extensions. ```python import sqlite_url import sqlite3 conn = sqlite3.connect(':memory:') conn.enable_load_extension(True) sqlite_url.load(conn) conn.enable_load_extension(False) conn.execute('select url_version()').fetchone() # ('v0.1.0') ``` -------------------------------- ### Python API - load(connection) Source: https://github.com/asg017/sqlite-url/blob/main/python/sqlite_url/README.md The `load(connection)` function loads the `sqlite-url` extension into the provided `sqlite3.Connection` object by calling `Connection.load_extension()`. ```APIDOC ## Python API - load(connection) ### Description Loads the `sqlite-url` extension on the given [`sqlite3.Connection`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection) object, calling [`Connection.load_extension()`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.load_extension). ### Method ```python sqlite_url.load(connection) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **connection** (sqlite3.Connection) - Required - The SQLite connection object to load the extension into. ### Request Example ```python import sqlite_url import sqlite3 conn = sqlite3.connect(':memory:') conn.enable_load_extension(True) sqlite_url.load(conn) conn.enable_load_extension(False) conn.execute('select url_version()').fetchone() # ('v0.1.0') ``` ### Response #### Success Response This function does not return a value, but it loads the extension into the connection. #### Response Example ```json { "status": "success", "message": "sqlite-url extension loaded successfully" } ``` ``` -------------------------------- ### Generate URL with Components using sqlite-url Source: https://context7.com/asg017/sqlite-url/llms.txt Constructs a URL by combining a base URL with specified components such as scheme, host, path, query, and fragment. It can also build URLs with authentication credentials. ```sql SELECT url( null, 'scheme', 'https', 'host', 'api.example.com', 'path', '/v1/users', 'query', 'page=1&limit=10', 'fragment', 'results' ); -- Result: 'https://api.example.com/v1/users?page=1&limit=10#results' SELECT url( 'https://github.com', 'path', '/asg017/sqlite-url', 'fragment', 'installation' ); -- Result: 'https://github.com/asg017/sqlite-url#installation' SELECT url( '', 'scheme', 'https', 'user', 'admin', 'password', 'secret123', 'host', 'secure.example.com', 'path', '/api/data' ); -- Result: 'https://admin:secret123@secure.example.com/api/data' ``` -------------------------------- ### Load sqlite-url Extension in Deno Source: https://context7.com/asg017/sqlite-url/llms.txt This Deno code snippet illustrates loading the sqlite-url extension into a Deno SQLite database. It uses the `load` function provided by the extension's Deno module. ```typescript import { Database } from "https://deno.land/x/sqlite3/mod.ts"; import { load } from "https://deno.land/x/sqlite_url/mod.ts"; const db = new Database(":memory:"); load(db); // Use the extension const [result] = db.prepare("SELECT url_valid('https://deno.land')").value<[number]>()!; console.log(result); // 1 ``` -------------------------------- ### Load sqlite-url extension in Python Source: https://github.com/asg017/sqlite-url/blob/main/README.md Shows how to load the sqlite-url extension in Python using the sqlite3 module. It enables extension loading and then loads the 'url0' extension before querying url_version(). ```python import sqlite3 con = sqlite3.connect(":memory:") con.enable_load_extension(True) con.load_extension("./url0") print(con.execute("select url_version()").fetchone()) # ('v0.0.1',) ``` -------------------------------- ### URL Generation Source: https://github.com/asg017/sqlite-url/blob/main/README.md Constructs a URL programmatically from its components. ```APIDOC ## url(base_url, key1, value1, key2, value2, ...) ### Description Generates a URL by combining a base URL with specified components (scheme, host, path, query, fragment). ### Method SQL Function ### Endpoint N/A ### Parameters #### Path Parameters - **base_url** (TEXT) - Optional - The base URL to build upon. If NULL, a new URL is constructed from scratch. - **keyN** (TEXT) - Required - The name of the URL component (e.g., 'scheme', 'host', 'path', 'query', 'fragment'). - **valueN** (TEXT) - Required - The value for the corresponding URL component. #### Query Parameters None #### Request Body None ### Request Example ```sql select url(null, 'scheme', 'https', 'host', 'alexgarcia.url', 'fragment', 'yeet' ); ``` ### Response #### Success Response (TEXT) - Returns the constructed URL as a string. #### Response Example ``` 'https://alexgarcia.url/#yeet' ``` ``` -------------------------------- ### Load sqlite-url Extension in Python Source: https://context7.com/asg017/sqlite-url/llms.txt This Python code demonstrates how to load the sqlite-url extension into an in-memory SQLite database using the `sqlite3` module. It shows two methods for loading: using a helper function and directly using the loadable path. ```python import sqlite3 import sqlite_url # Method 1: Using the helper function conn = sqlite3.connect(":memory:") conn.enable_load_extension(True) sqlite_url.load(conn) # Method 2: Using loadable_path directly conn.load_extension(sqlite_url.loadable_path()) # Use the extension result = conn.execute("SELECT url_host('https://github.com/asg017/sqlite-url')").fetchone() print(result) # ('github.com',) ``` -------------------------------- ### URL Parsing Functions Source: https://github.com/asg017/sqlite-url/blob/main/README.md Extract specific components from a given URL. ```APIDOC ## URL Parsing Functions ### Description These functions extract specific parts of a URL. ### Methods - `url_scheme(url)` - `url_host(url)` - `url_path(url)` - `url_fragment(url)` ### Endpoint N/A ### Parameters #### Path Parameters - **url** (TEXT) - Required - The URL string to parse. #### Query Parameters None #### Request Body None ### Request Examples ```sql select url_scheme('https://www.sqlite.org/vtab.html#usage'); -- 'https' select url_host('https://www.sqlite.org/vtab.html#usage'); -- 'www.sqlite.org' select url_path('https://www.sqlite.org/vtab.html#usage'); -- '/vtab.html' select url_fragment('https://www.sqlite.org/vtab.html#usage'); -- 'usage' ``` ### Response #### Success Response (TEXT) - Returns the extracted component of the URL as text. #### Response Examples ``` 'https' 'www.sqlite.org' '/vtab.html' 'usage' ``` ``` -------------------------------- ### Extract URL Host Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts and returns the host portion of a given URL. ```APIDOC ## GET /url_host ### Description Extracts and returns the host portion of a URL. ### Method GET ### Endpoint /url_host ### Parameters #### Query Parameters - **url_string** (string) - Required. The URL from which to extract the host. ### Request Example ```sql SELECT url_host('https://www.sqlite.org/docs.html'); ``` ### Response #### Success Response (200) - **host** (string) - The extracted host. #### Response Example ```json { "host": "www.sqlite.org" } ``` ``` -------------------------------- ### Extract URL Path Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts and returns the path portion of a given URL. ```APIDOC ## GET /url_path ### Description Extracts and returns the path portion of a URL. ### Method GET ### Endpoint /url_path ### Parameters #### Query Parameters - **url_string** (string) - Required. The URL from which to extract the path. ### Request Example ```sql SELECT url_path('https://github.com/asg017/sqlite-url'); ``` ### Response #### Success Response (200) - **path** (string) - The extracted URL path. #### Response Example ```json { "path": "/asg017/sqlite-url" } ``` ``` -------------------------------- ### Generate URL Source: https://context7.com/asg017/sqlite-url/llms.txt Generates a URL by combining a base URL with specified components. Supports setting scheme, host, path, query, fragment, user, password, and options. ```APIDOC ## POST /url ### Description Generates a URL by combining a base URL with specified components. ### Method POST ### Endpoint /url ### Parameters #### Query Parameters - **baseURL** (string) - Optional. The base URL to modify. - **scheme** (string) - Optional. The URL scheme (e.g., 'https'). - **host** (string) - Optional. The hostname. - **path** (string) - Optional. The URL path. - **query** (string) - Optional. The query string. - **fragment** (string) - Optional. The URL fragment. - **user** (string) - Optional. The username for authentication. - **password** (string) - Optional. The password for authentication. - **options** (string) - Optional. URL options. - **zoneid** (string) - Optional. Zone ID for IPv6 addresses. ### Request Example ```sql SELECT url( null, 'scheme', 'https', 'host', 'api.example.com', 'path', '/v1/users', 'query', 'page=1&limit=10', 'fragment', 'results' ); ``` ### Response #### Success Response (200) - **generated_url** (string) - The generated URL. #### Response Example ```json { "generated_url": "https://api.example.com/v1/users?page=1&limit=10#results" } ``` ``` -------------------------------- ### Validate URL Source: https://context7.com/asg017/sqlite-url/llms.txt Checks if a given string is a well-formed URL according to libcurl standards. Returns 1 if valid, 0 otherwise. ```APIDOC ## GET /url_valid ### Description Returns 1 if the provided string is a well-formed URL, 0 otherwise. ### Method GET ### Endpoint /url_valid ### Parameters #### Query Parameters - **url_string** (string) - Required. The string to validate. ### Request Example ```sql SELECT url_valid('https://www.sqlite.org/docs.html'); ``` ### Response #### Success Response (200) - **is_valid** (integer) - 1 if the URL is valid, 0 otherwise. #### Response Example ```json { "is_valid": 1 } ``` ``` -------------------------------- ### Load sqlite-url Extension into SQLite Connection Source: https://github.com/asg017/sqlite-url/blob/main/python/sqlite_url/README.md Loads the sqlite-url extension into a given sqlite3.Connection object. This enables the use of URL-related SQL functions within the connection. ```python import sqlite_url import sqlite3 conn = sqlite3.connect(':memory:') sqlite_url.load(conn) conn.execute('select url_version()').fetchone() # ('v0.1.0') ``` -------------------------------- ### Extract URL Scheme Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts and returns the scheme (protocol) portion of a given URL. ```APIDOC ## GET /url_scheme ### Description Extracts and returns the scheme (protocol) portion of a URL. ### Method GET ### Endpoint /url_scheme ### Parameters #### Query Parameters - **url_string** (string) - Required. The URL from which to extract the scheme. ### Request Example ```sql SELECT url_scheme('https://www.sqlite.org'); ``` ### Response #### Success Response (200) - **scheme** (string) - The extracted URL scheme. #### Response Example ```json { "scheme": "https" } ``` ``` -------------------------------- ### URL Query String Parsing Source: https://github.com/asg017/sqlite-url/blob/main/README.md Parses a URL's query string into a set of key-value pairs. ```APIDOC ## url_query(url) ### Description Parses the query string of a given URL and returns a table-valued function result. ### Method SQL Function ### Endpoint N/A ### Parameters #### Path Parameters - **url** (TEXT) - Required - The URL containing the query string. #### Query Parameters None #### Request Body None ### Request Example ```sql select * from url_query_each( url_query('https://api.census.gov/data/2020/acs/acs5?get=B01001_001E&for=county:*&in=state:06') ); ``` ### Response #### Success Response (TABLE) - Returns a table with columns 'name' and 'value' for each query parameter. #### Response Example ``` ┌──────┬─────────────┐ │ name │ value │ ├──────┼─────────────┤ │ get │ B01001_001E │ │ for │ county:* │ │ in │ state:06 │ └──────┴─────────────┘ ``` ``` -------------------------------- ### Parse URL Query String with url_query_each Source: https://context7.com/asg017/sqlite-url/llms.txt The url_query_each table function parses a given query string and returns each parameter as a row with 'name' and 'value' columns. Values are automatically URL-decoded. It can be used to analyze query parameters from simple strings or extracted from full URLs. ```sql -- Parse a simple query string SELECT * FROM url_query_each('q=sqlite&page=1&sort=desc'); /* ┌──────┬────────┐ │ name │ value │ ├──────┼────────┤ │ q │ sqlite │ │ page │ 1 │ │ sort │ desc │ └──────┴────────┘ */ -- Parse query string from a URL SELECT * FROM url_query_each( url_query('https://www.google.com/search?q=sqlite+extension&oq=sqlite&sourceid=chrome') ); /* ┌──────────┬─────────────────┐ │ name │ value │ ├──────────┼─────────────────┤ │ q │ sqlite extension│ │ oq │ sqlite │ │ sourceid │ chrome │ └──────────┴─────────────────┘ */ -- Extract specific parameter values SELECT value FROM url_query_each( url_query('https://api.example.com/search?category=books&limit=50&format=json') ) WHERE name = 'limit'; -- Result: '50' -- Analyze query parameters across multiple URLs SELECT requests.url, params.name, params.value FROM requests JOIN url_query_each(url_query(requests.url)) AS params WHERE params.name IN ('page', 'limit', 'offset'); ``` -------------------------------- ### URL Query String Generation Source: https://github.com/asg017/sqlite-url/blob/main/README.md Generates a URL-encoded query string from key-value pairs. ```APIDOC ## url_querystring(key1, value1, key2, value2, ...) ### Description Generates a URL-encoded query string from a list of key-value pairs. ### Method SQL Function ### Endpoint N/A ### Parameters #### Path Parameters - **keyN** (TEXT) - Required - The name of the query parameter. - **valueN** (TEXT) - Required - The value for the corresponding query parameter. #### Query Parameters None #### Request Body None ### Request Example ```sql select url_querystring( 'get', 'B01001_001E', 'for', 'county:*', 'in', 'state:06' ); ``` ### Response #### Success Response (TEXT) - Returns the generated URL-encoded query string. #### Response Example ``` 'get=B01001_001E&for=county:*&in=state:06' ``` ``` -------------------------------- ### Generate Request URL with sqlite-http and SQL Source: https://github.com/asg017/sqlite-url/blob/main/README.md Combines `sqlite-url` with `sqlite-http` to generate a URL for an API request and fetch its body. It uses `url` and `url_querystring` to build the complete URL. ```sql select http_get_body( url( 'https://api.census.gov', 'path', '/data/2020/acs/acs5', 'query', url_querystring( 'get', 'B01001_001E', 'for', 'county:*', 'in', 'state:06' ) ) ); /* ┌────────────────────────────────────┐ │ http_get_body( │ ├────────────────────────────────────┤ │ [["B01001_001E","state","county"], │ │ ["1661584","06","001"], │ │ ["1159","06","003"], │ │ ["223344","06","007"], │ │ ["21491","06","011"], │ │ ["1147788","06","013"], │ │ ["190345","06","017"], │ │ ... │ │ ["845599","06","111"] │ └────────────────────────────────────┘ */ ``` -------------------------------- ### Generate URL Query String (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Constructs a URL-encoded query string from a variable number of name-value pairs. Each pair is automatically escaped according to URL specifications. ```sql SELECT url_querystring('q', 'sqlite extensions', 'page', '1', 'sort', 'date'); -- Result: 'q=sqlite%20extensions&page=1&sort=date' SELECT url_querystring('filter', '{"type":"video"}', 'after', '2024-01-01'); -- Result: 'filter=%7B%22type%22%3A%22video%22%7D&after=2024-01-01' -- Build complete URLs with query strings SELECT url( 'https://api.census.gov', 'path', '/data/2020/acs/acs5', 'query', url_querystring( 'get', 'B01001_001E', 'for', 'county:*', 'in', 'state:06' ) ); -- Result: 'https://api.census.gov/data/2020/acs/acs5?get=B01001_001E&for=county%3A%2A&in=state%3A06' ``` -------------------------------- ### Extract options from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the options portion of a URL, which is a less common part of URL structure, often found in specific protocols like IMAP. Use this function to retrieve that specific segment if needed. ```sql select url_options('imap://user:pass;word@host/file'); ``` -------------------------------- ### Extract path from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the path component of a given URL string. This includes the leading slash and any subsequent path segments. ```sql select url_path('https://github.com/asg017/sqlite-url'); ``` -------------------------------- ### URL Validation Source: https://github.com/asg017/sqlite-url/blob/main/README.md Checks if a given string is a valid URL. ```APIDOC ## SELECT url_valid(url) ### Description Checks if the provided string is a valid URL. ### Method SQL Function ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql select url_valid('https://sqlite.org'); ``` ### Response #### Success Response (1 or 0) - **1**: if the URL is valid - **0**: if the URL is invalid #### Response Example ``` 1 ``` ``` -------------------------------- ### Extract URL Options (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts the options portion of a URL, typically used with specific schemes like IMAP. This is a rarely used component of URLs. ```sql SELECT url_options('imap://user:pass;option@host/file'); -- Result: 'option' ``` -------------------------------- ### URL Encode Text (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt URL-encodes (percent-encodes) a given string, making it safe for inclusion in URLs. Special characters like spaces, '=', '&', and '#' are converted to their percent-encoded equivalents. ```sql SELECT url_escape('hello world'); -- Result: 'hello%20world' SELECT url_escape('name=John Doe&city=New York'); -- Result: 'name%3DJohn%20Doe%26city%3DNew%20York' SELECT url_escape('special chars: &=?#'); -- Result: 'special%20chars%3A%20%26%3D%3F%23' -- Safely build a search URL SELECT 'https://example.com/search?q=' || url_escape('C++ programming'); -- Result: 'https://example.com/search?q=C%2B%2B%20programming' ``` -------------------------------- ### Extract scheme from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the scheme (protocol) portion of a given URL string, such as 'http' or 'https'. This function helps identify the protocol used by the URL. ```sql select url_scheme('https://github.com'); ``` ```sql select url_scheme('http://github.com'); ``` -------------------------------- ### Extract URL Query String Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts and returns the query string portion of a URL (without the leading '?'). ```APIDOC ## GET /url_query ### Description Extracts and returns the query string portion of a URL. ### Method GET ### Endpoint /url_query ### Parameters #### Query Parameters - **url_string** (string) - Required. The URL from which to extract the query string. ### Request Example ```sql SELECT url_query('https://google.com/search?q=sqlite&lang=en'); ``` ### Response #### Success Response (200) - **query_string** (string) - The extracted query string. #### Response Example ```json { "query_string": "q=sqlite&lang=en" } ``` ``` -------------------------------- ### Extract URL Scheme using sqlite-url Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts and returns the scheme (protocol) part of a given URL. This function is helpful for categorizing or grouping URLs based on their protocol. ```sql SELECT url_scheme('https://www.sqlite.org'); -- 'https' SELECT url_scheme('http://localhost:3000'); -- 'http' SELECT url_scheme('ftp://files.example.com'); -- 'ftp' SELECT url_scheme('mailto:user@example.com'); -- 'mailto' -- Group URLs by protocol SELECT url_scheme(url) AS protocol, COUNT(*) AS count FROM bookmarks GROUP BY url_scheme(url); ``` -------------------------------- ### Extract URL Zone ID (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts the zone ID from an IPv6 URL, which is appended after a '%' sign. This is relevant for network interfaces on certain operating systems. ```sql SELECT url_zoneid('http://[fe80::1%25eth0]/'); -- Result: 'eth0' SELECT url_zoneid('http://[ffaa::aa%2521]/'); -- Result: '21' ``` -------------------------------- ### Extract URL Port Number (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts the port number from a URL. Returns NULL if no explicit port is specified. Useful for identifying services running on non-standard ports. ```sql SELECT url_port('https://localhost:8080/api'); -- '8080' SELECT url_port('http://example.com:3000/app'); -- '3000' SELECT url_port('https://example.com/'); -- NULL (no explicit port) -- Find services running on non-standard ports SELECT url, url_port(url) AS port FROM services WHERE url_port(url) IS NOT NULL AND url_port(url) NOT IN ('80', '443'); ``` -------------------------------- ### Generate URL query string Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Creates a URL-encoded query string from a series of name-value pairs. Individual values are automatically escaped according to the URL standard. This is useful for constructing query parameters for URLs. ```sql select url_querystring( 'q', 'memes', 'tag', 'Bug Fix' ); ``` ```sql select url_querystring( 'q', 'memes', 'filters', '[{"type":"videos"}]', 'after', '2022-08-22T16:14:29.077Z' ); ``` ```sql select url( 'https://github.com/asg017/sqlite-url/issues', 'query', url_querystring('q', 'foo bar') ); ``` -------------------------------- ### Extract host from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the host portion of a given URL string. This function is useful for isolating the domain name from a complete URL. ```sql select url_host('https://github.com'); ``` -------------------------------- ### Validate URL format Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Checks if a given string is a well-formed URL according to libcurl's standards. Returns 1 if valid, 0 otherwise. An optional 'strict' parameter can be provided for more rigorous validation. ```sql select url_valid('https://google.com'); ``` ```sql select url_valid('invalid'); ``` -------------------------------- ### Extract URL Host using sqlite-url Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts and returns the host portion of a URL. This function is useful for identifying the domain or server associated with a URL. ```sql SELECT url_host('https://www.sqlite.org/docs.html'); -- 'www.sqlite.org' SELECT url_host('http://localhost:8080/api'); -- 'localhost' SELECT url_host('https://api.github.com/users'); -- 'api.github.com' -- Find all URLs from a specific domain SELECT * FROM links WHERE url_host(url) LIKE '%github.com'; ``` -------------------------------- ### Extract URL Path using sqlite-url Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts and returns the path component of a URL. This function helps in isolating the resource location within a URL, including the root path if no specific path is present. ```sql SELECT url_path('https://github.com/asg017/sqlite-url'); -- Result: '/asg017/sqlite-url' SELECT url_path('https://example.com/api/v1/users/123'); -- Result: '/api/v1/users/123' SELECT url_path('https://example.com'); -- Result: '/' -- Extract API versions from paths SELECT url_path(endpoint) AS api_path FROM api_calls WHERE url_path(endpoint) LIKE '/api/v%'; ``` -------------------------------- ### Iterate through URL query parameters Source: https://github.com/asg017/sqlite-url/blob/main/docs.md A table function that parses a query string and returns each key-value pair as a separate row. Both names and values are pre-escaped, following the URL standard parsing algorithm. Useful for processing complex query strings. ```sql select * from url_query_each('q=memes&filters=%5B%7B%22type%22%3A%22videos%22%7D%5D&after=2022-08-22T16%3A14%3A29.077Z'); ``` -------------------------------- ### URL-encode string Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Escapes a given text string according to URL encoding rules, replacing special characters with their percent-encoded equivalents. This is essential for safely including data in URLs. ```sql select url_escape('alex garcia, &='); ``` -------------------------------- ### Extract query string from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the query string portion of a given URL, excluding the leading question mark. This function can be used in conjunction with `url_query_each` to parse individual query parameters. ```sql select url_query('https://google.com/books?sort=asc'); ``` -------------------------------- ### Extract URL Password (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts the password from a URL containing authentication credentials. This function should be used with caution due to security implications. ```sql SELECT url_password('https://admin:password123@secure.example.com/data'); -- Result: 'password123' -- WARNING: Security audit - find URLs with embedded credentials SELECT url FROM api_endpoints WHERE url_password(url) IS NOT NULL; ``` -------------------------------- ### Extract URL Username (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts the username from a URL that includes authentication credentials. This function is useful for auditing or identifying access information within URLs. ```sql SELECT url_user('https://admin:password123@secure.example.com/data'); -- Result: 'admin' SELECT url_user('ftp://anonymous:email@ftp.example.com/files'); -- Result: 'anonymous' -- Audit URLs containing credentials SELECT url, url_user(url) AS username FROM connections WHERE url_user(url) IS NOT NULL; ``` -------------------------------- ### Validate URL Format using sqlite-url Source: https://context7.com/asg017/sqlite-url/llms.txt Checks if a given string is a well-formed URL according to the libcurl library's standards. Returns 1 for valid URLs and 0 for invalid ones. This function is useful for filtering and ensuring data integrity. ```sql SELECT url_valid('https://www.sqlite.org/docs.html'); -- 1 SELECT url_valid('http://localhost:8080/api'); -- 1 SELECT url_valid('ftp://files.example.com/data'); -- 1 SELECT url_valid('not a valid url'); -- 0 SELECT url_valid('missing-scheme.com'); -- 0 -- Use in WHERE clause to filter valid URLs SELECT url FROM links WHERE url_valid(url) = 1; ``` -------------------------------- ### URL Decode Text (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Decodes URL-encoded (percent-encoded) text back into its original form. This is the inverse operation of `url_escape` and is used to interpret data within URLs. ```sql SELECT url_unescape('hello%20world'); -- Result: 'hello world' SELECT url_unescape('C%2B%2B%20programming'); -- Result: 'C++ programming' SELECT url_unescape('name%3DJohn%20Doe%26city%3DNew%20York'); -- Result: 'name=John Doe&city=New York' -- Decode query parameters for analysis SELECT url_unescape(url_query(url)) AS decoded_params FROM search_logs; ``` -------------------------------- ### Extract URL Fragment (SQL) Source: https://context7.com/asg017/sqlite-url/llms.txt Extracts the fragment (anchor) portion of a URL, excluding the leading '#'. Useful for identifying specific sections within a web page. ```sql SELECT url_fragment('https://www.sqlite.org/vtab.html#usage'); -- Result: 'usage' SELECT url_fragment('https://docs.example.com/guide#section-3'); -- Result: 'section-3' -- Find documentation links with specific sections SELECT * FROM docs WHERE url_fragment(url) = 'installation'; ``` -------------------------------- ### Extract password from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the password portion of a URL, used in conjunction with the username for authentication. This function extracts the password string from the URL. ```sql select url_password('https://admin:password@google.com'); ``` -------------------------------- ### Extract user from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the username portion of a URL, typically found in URLs that include authentication credentials. This function isolates the username from the URL string. ```sql select url_user('https://admin:password@google.com'); ``` -------------------------------- ### URL-unescape string Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Unescapes a given text string that has been previously URL-encoded. This function converts percent-encoded characters back to their original form. ```sql select url_unescape('alex%20garcia%2C%20%26%3D'); ``` -------------------------------- ### Parse URL Query Parameters with SQLite Source: https://github.com/asg017/sqlite-url/blob/main/docs.md The `url_query()` function parses a given URL and extracts its query string parameters. It is typically used in conjunction with `url_query_each()` to process these parameters. This function takes a single string argument representing the URL. ```sql select * from url_query_each( url_query('https://www.google.com/search?q=memes&rlz=1C5CHFA_enUS915US915&oq=memes&aqs=chrome..69i57j0i433i512j0i131i433i512j0i512j46i433i512j0i433i512j0i512l2j0i131i433i512j0i512.817j0j7&sourceid=chrome&ie=UTF-8') ); ``` -------------------------------- ### Extract zone ID from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the zone ID from a URL, primarily useful for IPv6 addresses that include scope information. This function extracts that specific identifier. ```sql select url_zoneid('http://[ffaa::aa%21]/'); ``` -------------------------------- ### Extract fragment from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the fragment identifier (the part after the '#') of a given URL string. This is often used for client-side navigation within a web page. ```sql select url_fragment('https://google.com#a'); ``` -------------------------------- ### Extract port from URL Source: https://github.com/asg017/sqlite-url/blob/main/docs.md Returns the port number specified in a URL string. This function is useful for identifying the network port the URL is intended to connect to. ```sql select url_port('https://google.com:8080'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.