{"id":15050596,"url":"https://github.com/asg017/sqlite-url","last_synced_at":"2025-04-10T02:14:50.405Z","repository":{"id":98916989,"uuid":"520244809","full_name":"asg017/sqlite-url","owner":"asg017","description":"A SQLite extension for parsing, generating, and querying URLs and query strings","archived":false,"fork":false,"pushed_at":"2025-02-08T22:39:54.000Z","size":2560,"stargazers_count":41,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T02:14:42.710Z","etag":null,"topics":["sqlite","sqlite-extension"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asg017.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-01T19:54:03.000Z","updated_at":"2025-03-16T18:26:38.000Z","dependencies_parsed_at":"2024-09-24T21:27:48.701Z","dependency_job_id":"c99402e9-5697-42da-a4ea-e7464e967c5a","html_url":"https://github.com/asg017/sqlite-url","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asg017","download_url":"https://codeload.github.com/asg017/sqlite-url/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142903,"owners_count":21054671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sqlite","sqlite-extension"],"created_at":"2024-09-24T21:27:42.554Z","updated_at":"2025-04-10T02:14:50.382Z","avatar_url":"https://github.com/asg017.png","language":"C","readme":"# sqlite-url\n\nA SQLite extension for parsing and generating URLs and query strings. Based on libcurl's [URL API](https://curl.se/libcurl/c/libcurl-url.html)\n\nTry it out in your browser and learn more in [Introducing sqlite-url: A SQLite extension for parsing and generating URLs](https://observablehq.com/@asg017/introducing-sqlite-url) (September 2022)\n\n## Usage\n\n```sql\n.load ./url0\nselect url_valid('https://sqlite.org'); -- 1\n```\n\nExtract specific parts from a given URL.\n\n```sql\nselect url_scheme('https://www.sqlite.org/vtab.html#usage'); -- 'https'\nselect url_host('https://www.sqlite.org/vtab.html#usage'); -- 'www.sqlite.org'\nselect url_path('https://www.sqlite.org/vtab.html#usage'); -- '/vtab.html'\nselect url_fragment('https://www.sqlite.org/vtab.html#usage'); -- 'usage'\n```\n\nGenerate a URL programmatically.\n\n```sql\nselect url(null,\n  'scheme', 'https',\n  'host', 'alexgarcia.url',\n  'fragment', 'yeet'\n); -- 'https://alexgarcia.url/#yeet'\n```\n\nIterate through all parameters in a URL's query string.\n\n```sql\n\nselect *\nfrom url_query_each(\n  url_query('https://api.census.gov/data/2020/acs/acs5?get=B01001_001E\u0026for=county:*\u0026in=state:06')\n);\n/*\n┌──────┬─────────────┐\n│ name │    value    │\n├──────┼─────────────┤\n│ get  │ B01001_001E │\n│ for  │ county:*    │\n│ in   │ state:06    │\n└──────┴─────────────┘\n*/\n```\n\nUse with [sqlite-http](https://github.com/asg017/sqlite-http) to generate URLs to request.\n\n```sql\nselect http_get_body(\n  url(\n    'https://api.census.gov',\n    'path', '/data/2020/acs/acs5',\n    'query', url_querystring(\n      'get', 'B01001_001E',\n      'for', 'county:*',\n      'in', 'state:06'\n    )\n  )\n);\n/*\n┌────────────────────────────────────┐\n│           http_get_body(           │\n├────────────────────────────────────┤\n│ [[\"B01001_001E\",\"state\",\"county\"], │\n│ [\"1661584\",\"06\",\"001\"],            │\n│ [\"1159\",\"06\",\"003\"],               │\n│ [\"223344\",\"06\",\"007\"],             │\n│ [\"21491\",\"06\",\"011\"],              │\n│ [\"1147788\",\"06\",\"013\"],            │\n│ [\"190345\",\"06\",\"017\"],             │\n│               ...                  │\n│ [\"845599\",\"06\",\"111\"]]             │\n└────────────────────────────────────┘\n*/\n```\n\nUse with [sqlite-path](https://github.com/asg017/sqlite-path) to safely generate paths for a URL.\n\n```sql\n\nselect url(\n  'https://github.com',\n  'path', path_join('/', 'asg017', 'sqlite-url', 'issues', '1')\n);\n-- 'https://github.com/asg017/sqlite-url/issues/1'\n```\n\n## Documentation\n\nSee [`docs.md`](./docs.md) for a full API reference.\n\n## Installing\n\n| Language       | Install                                                    |                                                                                                                                                                                           |\n| -------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Python         | `pip install sqlite-url`                                   | [![PyPI](https://img.shields.io/pypi/v/sqlite-url.svg?color=blue\u0026logo=python\u0026logoColor=white)](https://pypi.org/project/sqlite-url/)                                                      |\n| Datasette      | `datasette install datasette-sqlite-url`                   | [![Datasette](https://img.shields.io/pypi/v/datasette-sqlite-url.svg?color=B6B6D9\u0026label=Datasette+plugin\u0026logoColor=white\u0026logo=python)](https://datasette.io/plugins/datasette-sqlite-url) |\n| Node.js        | `npm install sqlite-url`                                   | [![npm](https://img.shields.io/npm/v/sqlite-url.svg?color=green\u0026logo=nodedotjs\u0026logoColor=white)](https://www.npmjs.com/package/sqlite-url)                                                |\n| Deno           | [`deno.land/x/sqlite_url`](https://deno.land/x/sqlite_url) | [![deno.land/x release](https://img.shields.io/github/v/release/asg017/sqlite-url?color=fef8d2\u0026include_prereleases\u0026label=deno.land%2Fx\u0026logo=deno)](https://deno.land/x/sqlite_url)        |\n| Ruby           | `gem install sqlite-url`                                   | ![Gem](https://img.shields.io/gem/v/sqlite-url?color=red\u0026logo=rubygems\u0026logoColor=white)                                                                                                   |\n| Github Release |                                                            | ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/asg017/sqlite-url?color=lightgrey\u0026include_prereleases\u0026label=Github+release\u0026logo=github)                     |\n\n\u003c!--\n| Elixir         | [`hex.pm/packages/sqlite_url`](https://hex.pm/packages/sqlite_url) | [![Hex.pm](https://img.shields.io/hexpm/v/sqlite_url?color=purple\u0026logo=elixir)](https://hex.pm/packages/sqlite_url)                                                                       |\n| Go             | `go get -u github.com/asg017/sqlite-url/bindings/go`               | [![Go Reference](https://pkg.go.dev/badge/github.com/asg017/sqlite-url/bindings/go.svg)](https://pkg.go.dev/github.com/asg017/sqlite-url/bindings/go)                                     |\n| Rust           | `cargo add sqlite-url`                                             | [![Crates.io](https://img.shields.io/crates/v/sqlite-url?logo=rust)](https://crates.io/crates/sqlite-url)                                                                                 |\n--\u003e\n\nThe [Releases page](https://github.com/asg017/sqlite-url/releases) contains pre-built binaries for Linux amd6 and MacOS amd64 (no arm).\n\n### As a loadable extension\n\nIf you want to use `sqlite-url` as a [Runtime-loadable extension](https://www.sqlite.org/loadext.html), Download the `url0.dylib` (for MacOS) or `url0.so` (Linux) file from a release and load it into your SQLite environment.\n\n\u003e **Note:**\n\u003e The `0` in the filename (`url0.dylib`/ `url0.so`) denotes the major version of `sqlite-url`. Currently `sqlite-url` is pre v1, so expect breaking changes in future versions.\n\nFor example, if you are using the [SQLite CLI](https://www.sqlite.org/cli.html), you can load the library like so:\n\n```sql\n.load ./url0\nselect url_version();\n-- v0.0.1\n```\n\nOr in Python, using the builtin [sqlite3 module](https://docs.python.org/3/library/sqlite3.html):\n\n```python\nimport sqlite3\n\ncon = sqlite3.connect(\":memory:\")\n\ncon.enable_load_extension(True)\ncon.load_extension(\"./url0\")\n\nprint(con.execute(\"select url_version()\").fetchone())\n# ('v0.0.1',)\n```\n\nOr in Node.js using [better-sqlite3](https://github.com/WiseLibs/better-sqlite3):\n\n```javascript\nconst Database = require(\"better-sqlite3\");\nconst db = new Database(\":memory:\");\n\ndb.loadExtension(\"./url0\");\n\nconsole.log(db.prepare(\"select url_version()\").get());\n// { 'html_version()': 'v0.0.1' }\n```\n\nOr with [Datasette](https://datasette.io/):\n\n```\ndatasette data.db --load-extension ./url0\n```\n\n## See also\n\n- [sqlite-path](https://github.com/asg017/sqlite-path), parsing/generating paths (pairs well with `url_path()` and `url()`)\n- [sqlite-http](https://github.com/asg017/sqlite-http), for making HTTP requests in SQLite\n- [sqlite-html](https://github.com/asg017/sqlite-html), for parsing HTML documents\n- [sqlite-lines](https://github.com/asg017/sqlite-lines), for reading large files line-by-line\n- [nalgeon/sqlean](https://github.com/nalgeon/sqlean), several pre-compiled handy SQLite functions, in C\n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasg017%2Fsqlite-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasg017%2Fsqlite-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasg017%2Fsqlite-url/lists"}