{"id":17694961,"url":"https://github.com/asg017/sqlite-path","last_synced_at":"2025-09-11T16:12:27.894Z","repository":{"id":98917017,"uuid":"520243633","full_name":"asg017/sqlite-path","owner":"asg017","description":"A SQLite extension for parsing, generating, and querying paths","archived":false,"fork":false,"pushed_at":"2023-10-07T05:57:19.000Z","size":2638,"stargazers_count":37,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-07T19:22:57.853Z","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:49:33.000Z","updated_at":"2025-08-27T09:28:32.000Z","dependencies_parsed_at":"2024-10-24T16:49:34.462Z","dependency_job_id":"560d3b9b-3d22-45a5-b83a-bb32fa665c5e","html_url":"https://github.com/asg017/sqlite-path","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/asg017/sqlite-path","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asg017","download_url":"https://codeload.github.com/asg017/sqlite-path/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-path/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274665820,"owners_count":25327312,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-24T13:50:39.478Z","updated_at":"2025-09-11T16:12:27.844Z","avatar_url":"https://github.com/asg017.png","language":"C","readme":"# sqlite-path\n\nA loadable SQLite extension for parsing, generating, and querying paths. Based on [cwalk](https://github.com/likle/cwalk)\n\nTry it out in your browser and learn more in [_Introducing sqlite-path: A SQLite extension for parsing and generating file paths_](https://observablehq.com/@asg017/introducing-sqlite-path) (August 2022)\n\n## Usage\n\n```sql\n.load ./path0\nselect path_dirname('foo/bar.txt'); -- 'foo/'\nselect path_basename('foo/bar.txt'); -- 'bar.txt'\nselect path_extension('foo/bar.txt'); -- '.txt'\n\nselect path_part_at('foo/bar/baz.txt', 0); -- 'foo'\nselect path_part_at('foo/bar/baz.txt', 1); -- 'bar'\nselect path_part_at('foo/bar/baz.txt', -1); -- 'baz.txt'\n```\n\nIterate through all parts in a path.\n\n```sql\n\nselect *\nfrom path_parts('/usr/bin/sqlite3');\n\n/*\n┌────────┬─────────┐\n│  type  │  part   │\n├────────┼─────────┤\n│ normal │ usr     │\n│ normal │ bin     │\n│ normal │ sqlite3 │\n└────────┴─────────┘\n*/\n```\n\nInside a ZIP archive of the [SQLite source code](https://github.com/sqlite/sqlite), find the top 5 deepest `.c` source code files under the `ext/` directory (using SQLite's [ZIP support](https://www.sqlite.org/zipfile.html)).\n\n```sql\nselect\n  name,\n  path_length(name) as depth\nfrom zipfile('sqlite.archive.master.zip')\nwhere\n  -- under the ext/ directory\n  path_part_at(name, 1) == 'ext'\n  -- ends in \".c\"\n  and path_extension(name) == '.c'\norder by 2 desc\nlimit 5;\n\n/*\n┌────────────────────────────────────────────┬───────┐\n│                    name                    │ depth │\n├────────────────────────────────────────────┼───────┤\n│ sqlite-master/ext/fts3/tool/fts3view.c     │ 5     │\n│ sqlite-master/ext/lsm1/lsm-test/lsmtest1.c │ 5     │\n│ sqlite-master/ext/lsm1/lsm-test/lsmtest2.c │ 5     │\n│ sqlite-master/ext/lsm1/lsm-test/lsmtest3.c │ 5     │\n│ sqlite-master/ext/lsm1/lsm-test/lsmtest4.c │ 5     │\n└────────────────────────────────────────────┴───────┘\n*/\n```\n\nMake a histogram of the count of file extensions in the current directory, using [`fsdir()`](https://www.sqlite.org/cli.html#file_i_o_functions).\n\n```sql\n\nselect\n  path_extension(name),\n  count(*),\n  printf('%.*c', count(*), '*') as bar\nfrom fsdir('.')\nwhere path_extension(name) is not null\ngroup by 1\norder by 2 desc\nlimit 6;\n\n/*\n┌──────────────────────┬──────────┬────────────────────────────────────┐\n│ path_extension(name) │ count(*) │                bar                 │\n├──────────────────────┼──────────┼────────────────────────────────────┤\n│ .md                  │ 34       │ ********************************** │\n│ .sample              │ 26       │ **************************         │\n│ .c                   │ 21       │ *********************              │\n│ .css                 │ 5        │ *****                              │\n│ .yml                 │ 4        │ ****                               │\n│ .h                   │ 4        │ ****                               │\n└──────────────────────┴──────────┴────────────────────────────────────┘\n*/\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-path`                                   | [![PyPI](https://img.shields.io/pypi/v/sqlite-path.svg?color=blue\u0026logo=python\u0026logoColor=white)](https://pypi.org/project/sqlite-path/)                                                      |\n| Datasette      | `datasette install datasette-sqlite-path`                   | [![Datasette](https://img.shields.io/pypi/v/datasette-sqlite-path.svg?color=B6B6D9\u0026label=Datasette+plugin\u0026logoColor=white\u0026logo=python)](https://datasette.io/plugins/datasette-sqlite-path) |\n| Node.js        | `npm install sqlite-path`                                   | [![npm](https://img.shields.io/npm/v/sqlite-path.svg?color=green\u0026logo=nodedotjs\u0026logoColor=white)](https://www.npmjs.com/package/sqlite-path)                                                |\n| Deno           | [`deno.land/x/sqlite_path`](https://deno.land/x/sqlite_path) | [![deno.land/x release](https://img.shields.io/github/v/release/asg017/sqlite-path?color=fef8d2\u0026include_prereleases\u0026label=deno.land%2Fx\u0026logo=deno)](https://deno.land/x/sqlite_path)        |\n| Ruby           | `gem install sqlite-path`                                   | ![Gem](https://img.shields.io/gem/v/sqlite-path?color=red\u0026logo=rubygems\u0026logoColor=white)                                                                                                   |\n| Github Release |                                                            | ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/asg017/sqlite-path?color=lightgrey\u0026include_prereleases\u0026label=Github+release\u0026logo=github)                     |\n\n\u003c!--\n| Elixir         | [`hex.pm/packages/sqlite_path`](https://hex.pm/packages/sqlite_path) | [![Hex.pm](https://img.shields.io/hexpm/v/sqlite_path?color=purple\u0026logo=elixir)](https://hex.pm/packages/sqlite_path)                                                                       |\n| Go             | `go get -u github.com/asg017/sqlite-path/bindings/go`               | [![Go Reference](https://pkg.go.dev/badge/github.com/asg017/sqlite-path/bindings/go.svg)](https://pkg.go.dev/github.com/asg017/sqlite-path/bindings/go)                                     |\n| Rust           | `cargo add sqlite-path`                                             | [![Crates.io](https://img.shields.io/crates/v/sqlite-path?logo=rust)](https://crates.io/crates/sqlite-path)                                                                                 |\n--\u003e\n\nThe [Releases page](https://github.com/asg017/sqlite-path/releases) contains pre-built binaries for Linux amd64, MacOS amd64 (no arm), and Windows.\n\n### As a loadable extension\n\nIf you want to use `sqlite-path` as a [Runtime-loadable extension](https://www.sqlite.org/loadext.html), Download the `path0.dylib` (for MacOS), `path0.so` (Linux), or `path0.dll` (Windows) file from a release and load it into your SQLite environment.\n\n\u003e **Note:**\n\u003e The `0` in the filename (`path0.dylib`/ `path0.so`/`path0.dll`) denotes the major version of `sqlite-path`. Currently `sqlite-path` 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 ./path0\nselect path_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(\"./path0\")\n\nprint(con.execute(\"select path_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(\"./path0\");\n\nconsole.log(db.prepare(\"select path_version()\").get());\n// { 'html_version()': 'v0.0.1' }\n```\n\nOr with [Datasette](https://datasette.io/):\n\n```\ndatasette data.db --load-extension ./path0\n```\n\n## See also\n\n- [sqlite-url](https://github.com/asg017/sqlite-url), for parsing and generating URLs (pairs well with this library)\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-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasg017%2Fsqlite-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasg017%2Fsqlite-path/lists"}