{"id":14563816,"url":"https://github.com/asg017/sqlite-jsonschema","last_synced_at":"2025-10-05T01:17:53.514Z","repository":{"id":65520197,"uuid":"561895986","full_name":"asg017/sqlite-jsonschema","owner":"asg017","description":"A SQLite extension for validating JSON objects with JSON Schema","archived":false,"fork":false,"pushed_at":"2023-08-06T00:29:45.000Z","size":270,"stargazers_count":52,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-30T19:41:46.386Z","etag":null,"topics":["sqlite","sqlite-extension"],"latest_commit_sha":null,"homepage":"https://alexgarcia.xyz/sqlite-jsonschema","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","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":"LICENSE-APACHE","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-11-04T18:34:59.000Z","updated_at":"2025-09-08T13:18:29.000Z","dependencies_parsed_at":"2024-09-07T03:21:00.906Z","dependency_job_id":"bf2456a6-c493-4d3b-bd63-1a4d42332dfb","html_url":"https://github.com/asg017/sqlite-jsonschema","commit_stats":{"total_commits":62,"total_committers":1,"mean_commits":62.0,"dds":0.0,"last_synced_commit":"fc24bbb8203d1ea619f11d39c7366e19e54a46aa"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/asg017/sqlite-jsonschema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-jsonschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-jsonschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-jsonschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-jsonschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asg017","download_url":"https://codeload.github.com/asg017/sqlite-jsonschema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asg017%2Fsqlite-jsonschema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278268955,"owners_count":25959101,"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-10-04T02:00:05.491Z","response_time":63,"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-09-07T02:05:26.757Z","updated_at":"2025-10-05T01:17:53.480Z","avatar_url":"https://github.com/asg017.png","language":"TypeScript","readme":"# sqlite-jsonschema\n\nA SQLite extension for validating JSON objects with [JSON Schema](https://json-schema.org/). Based on [`sqlite-loadable-rs`](https://github.com/asg017/sqlite-loadable-rs) and the [`jsonschema` crate](https://crates.io/crates/jsonschema).\n\nIf your company or organization finds this library useful, consider [supporting my work](#supporting)!\n\n## Usage\n\n```sql\n.load ./jsonschema0\nselect jsonschema_matches('{\"maxLength\": 5}', json_quote('alex'));\n```\n\nUse with SQLite's [`CHECK` constraints](https://www.sqlite.org/lang_createtable.html#check_constraints) to validate JSON columns before inserting into a table.\n\n```sql\ncreate table students(\n  -- ensure that JSON objects stored in the data column have \"firstName\" strings,\n  -- \"lastName\" strings, and \"age\" integers that are greater than 0.\n  data json check (\n    jsonschema_matches(\n      json('\n        {\n          \"type\": \"object\",\n          \"properties\": {\n            \"firstName\": {\n              \"type\": \"string\"\n            },\n            \"lastName\": {\n              \"type\": \"string\"\n            },\n            \"age\": {\n              \"type\": \"integer\",\n              \"minimum\": 0\n            }\n          }\n        }\n        '),\n      data\n    )\n  )\n);\n\ninsert into students(data)\n  values ('{\"firstName\": \"Alex\", \"lastName\": \"Garcia\", \"age\": 100}');\n-- ✓\n\n\ninsert into students(data)\n  values ('{\"firstName\": \"Alex\", \"lastName\": \"Garcia\", \"age\": -1}');\n-- Runtime error: CHECK constraint failed: jsonschema_matches\n\n```\n\nFind all the values in a column that don't match a JSON Schema.\n\n```sql\nselect\n  rowid,\n  jsonschema_matches(\n    '{\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"number\"\n      }\n    }',\n    foo\n  ) as valid\nfrom bar\nwhere not valid;\n```\n\n## Installing\n\n| Language       | Install                                                                  |                                                                                                                                                                                                         |\n| -------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Python         | `pip install sqlite-jsonschema`                                          | [![PyPI](https://img.shields.io/pypi/v/sqlite-jsonschema.svg?color=blue\u0026logo=python\u0026logoColor=white)](https://pypi.org/project/sqlite-jsonschema/)                                                      |\n| Datasette      | `datasette install datasette-sqlite-jsonschema`                          | [![Datasette](https://img.shields.io/pypi/v/datasette-sqlite-jsonschema.svg?color=B6B6D9\u0026label=Datasette+plugin\u0026logoColor=white\u0026logo=python)](https://datasette.io/plugins/datasette-sqlite-jsonschema) |\n| Node.js        | `npm install sqlite-jsonschema`                                          | [![npm](https://img.shields.io/npm/v/sqlite-jsonschema.svg?color=green\u0026logo=nodedotjs\u0026logoColor=white)](https://www.npmjs.com/package/sqlite-jsonschema)                                                |\n| Deno           | [`deno.land/x/sqlite_jsonschema`](https://deno.land/x/sqlite_jsonschema) | [![deno.land/x release](https://img.shields.io/github/v/release/asg017/sqlite-jsonschema?color=fef8d2\u0026include_prereleases\u0026label=deno.land%2Fx\u0026logo=deno)](https://deno.land/x/sqlite_jsonschema)        |\n| Ruby           | `gem install sqlite-jsonschema`                                          | ![Gem](https://img.shields.io/gem/v/sqlite-jsonschema?color=red\u0026logo=rubygems\u0026logoColor=white)                                                                                                          |\n| Github Release |                                                                          | ![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/asg017/sqlite-jsonschema?color=lightgrey\u0026include_prereleases\u0026label=Github+release\u0026logo=github)                            |\n| Rust           | `cargo add sqlite-jsonschema`                                            | [![Crates.io](https://img.shields.io/crates/v/sqlite-jsonschema?logo=rust)](https://crates.io/crates/sqlite-jsonschema)                                                                                 |\n\n\u003c!--\n| Elixir         | [`hex.pm/packages/sqlite_jsonschema`](https://hex.pm/packages/sqlite_jsonschema) | [![Hex.pm](https://img.shields.io/hexpm/v/sqlite_jsonschema?color=purple\u0026logo=elixir)](https://hex.pm/packages/sqlite_jsonschema)                                                                       |\n| Go             | `go get -u github.com/asg017/sqlite-jsonschema/bindings/go`               | [![Go Reference](https://pkg.go.dev/badge/github.com/asg017/sqlite-jsonschema/bindings/go.svg)](https://pkg.go.dev/github.com/asg017/sqlite-jsonschema/bindings/go)                                     |\n--\u003e\n\n`sqlite-jsonschema` is distributed on pip, npm, and https://deno.land/x for Python, Node.js, and Deno programmers. There are also pre-built extensions available for use in other environments.\n\n### Python\n\nFor Python developers, use the [`sqlite-jsonschema` Python package](https://pypi.org/package/sqlite-jsonschema/):\n\n```\npip install sqlite-jsonschema\n```\n\nThe `sqlite-jsonschema` extension can then be loaded into a [`sqlite3` Connection object](https://docs.python.org/3/library/sqlite3.html#connection-objects).\n\n```python\nimport sqlite3\nimport sqlite_jsonschema\n\ndb = sqlite3.connect(':memory:')\nsqlite_jsonschema.load(db)\ndb.execute('select jsonschema_version(), jsonschema()').fetchone()\n```\n\nSee [_Using `sqlite-jsonschema` with Python_](https://alexgarcia.jsonschema/sqlite-jsonschema/usage/python.html) for details.\n\n### Node.js\n\nFor Node.js developers, use the [`sqlite-jsonschema` NPM package](https://www.npmjs.com/package/sqlite-jsonschema):\n\n```\nnpm install sqlite-jsonschema\n```\n\nThe `sqlite-jsonschema` extension can then be loaded into a [`better-sqlite3`](https://github.com/WiseLibs/better-sqlite3) or [`node-sqlite3`](https://github.com/TryGhost/node-sqlite3) connection.\n\n```javascript\nimport Database from \"better-sqlite3\";\nimport * as sqlite_jsonschema from \"sqlite-jsonschema\";\n\nconst db = new Database(\":memory:\");\n\ndb.loadExtension(sqlite_jsonschema.getLoadablePath());\n\nconst version = db.prepare(\"select jsonschema_version()\").pluck().get();\nconsole.log(version); // \"v0.2.0\"\n```\n\nSee [_Using `sqlite-jsonschema` with Node.js_](https://alexgarcia.jsonschema/sqlite-jsonschema/usage/node.html) for details.\n\n### Deno\n\nFor [Deno](https://deno.land/) developers, use the [x/sqlite_jsonschema](https://deno.land/x/sqlite_jsonschema@v0.2.2) Deno module with [`x/sqlite3`](https://deno.land/x/sqlite3@0.8.1).\n\n```javascript\nimport { Database } from \"https://deno.land/x/sqlite3@0.8.0/mod.ts\";\nimport * as sqlite_jsonschema from \"https://deno.land/x/sqlite_jsonschema/mod.ts\";\n\nconst db = new Database(\":memory:\");\n\ndb.enableLoadExtension = true;\ndb.loadExtension(sqlite_jsonschema.getLoadablePath());\n\nconst [version] = db\n  .prepare(\"select jsonschema_version()\")\n  .value\u003c[string]\u003e()!;\n\nconsole.log(version);\n```\n\nSee [_Using `sqlite-jsonschema` with Deno_](https://alexgarcia.jsonschema/sqlite-jsonschema/usage/deno.html) for details.\n\n### Datasette\n\nFor [Datasette](https://datasette.io/), use the [`datasette-sqlite-jsonschema` plugin](https://datasette.io/plugins/datasette-sqlite-jsonschema) to include `sqlite-jsonschema` functions to your Datasette instances.\n\n```\ndatasette install datasette-sqlite-jsonschema\n```\n\nSee [_Using `sqlite-jsonschema` with Datasette_](https://alexgarcia.jsonschema/sqlite-jsonschema/usage/datasette.html) for details.\n\n### `sqlite3` CLI\n\nFor [the `sqlite3` CLI](https://sqlite.org/cli.html), either [download a pre-compiled extension from the Releases page](https://github.com/asg017/sqlite-jsonschema/releases) or [build it yourself](#building-from-source). Then use the [`.load` dot command](https://sqlite.org/cli.html#loading_extensions).\n\n```sql\n.load ./jsonschema0\nselect jsonschema_version();\n'v0.2.1'\n```\n\n### As a loadable extension\n\nIf you're using `sqlite-jsonschema` in a different way from those listed above, then [download a pre-compiled extension from the Releases page](https://github.com/asg017/sqlite-jsonschema/releases) and load it into your environment. Download the `jsonschema0.dylib` (for MacOS), `jsonschema0.so` (Linux), or `jsonschema0.dll` (Windows) file from a release and load it into your SQLite environment.\n\n\u003e **Note:**\n\u003e The `0` in the filename (`jsonschema0.dylib`/ `jsonschema0.so`/`jsonschema0.dll`) denotes the major version of `sqlite-jsonschema`. Currently `sqlite-jsonschema` is pre v1, so expect breaking changes in future versions.\n\nChances are there is some method called \"loadExtension\" or \"load_extension\" in the SQLite client library you are using. Alternatively, as a last resort, use [the `load_extension()` SQL function](https://www.sqlite.org/lang_corefunc.html#load_extension).\n\n### Building from source\n\nMake sure you have [Rust](https://www.rust-lang.org/tools/install), make, and a C compiler installed. Then `git clone` this repository and run `make loadable-release`.\n\n```\ngit clone https://github.com/asg017/sqlite-jsonschema.git\ncd sqlite-jsonschema\nmake loadable-release\n```\n\nOnce complete, your compiled extension will appear under `dist/release/`, either as `jsonschema0.so`, `jsonschema0.dylib`, or `jsonschema0.dll`, depending on your operating system.\n\n## Documentation\n\nSee [the full API Reference](https://alexgarcia.jsonschema/sqlite-jsonschema/reference.html) for every `sqlite-jsonschema` SQL function.\n\n## Supporting\n\nI (Alex 👋🏼) spent a lot of time and energy on this project and [many other open source projects](https://github.com/asg017?tab=repositories\u0026q=\u0026type=\u0026language=\u0026sort=stargazers). If your company or organization uses this library (or you're feeling generous), then please [consider supporting my work](https://alexgarcia.jsonschema/work.html), or share this project with a friend!\n\n## See also\n\n- [`sqlite-xsv`](https://github.com/asg017/sqlite-xsv), A SQLite extension for working with CSVs\n- [`sqlite-http`](https://github.com/asg017/sqlite-http), A SQLite extension for making HTTP requests\n- [`sqlite-loadable-rs`](https://github.com/asg017/sqlite-loadable-rs), A framework for writing SQLite extensions in Rust\n","funding_links":[],"categories":["sqlite"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasg017%2Fsqlite-jsonschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasg017%2Fsqlite-jsonschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasg017%2Fsqlite-jsonschema/lists"}