{"id":31285712,"url":"https://github.com/outskirtslabs/datahike-sqlite","last_synced_at":"2025-09-24T08:13:32.976Z","repository":{"id":289285480,"uuid":"970650666","full_name":"outskirtslabs/datahike-sqlite","owner":"outskirtslabs","description":"A SQLite storage backend for Datahike, the open datalog database","archived":false,"fork":false,"pushed_at":"2025-09-08T18:46:10.000Z","size":38,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T02:54:07.330Z","etag":null,"topics":["clojure","datahike","datalog","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/outskirtslabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-04-22T10:29:59.000Z","updated_at":"2025-09-08T18:46:14.000Z","dependencies_parsed_at":"2025-04-22T14:38:43.876Z","dependency_job_id":"f71d5416-edd8-446a-988d-c92e84dc2b11","html_url":"https://github.com/outskirtslabs/datahike-sqlite","commit_stats":null,"previous_names":["ramblurr/datahike-sqlite","outskirtslabs/datahike-sqlite"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/outskirtslabs/datahike-sqlite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outskirtslabs%2Fdatahike-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outskirtslabs%2Fdatahike-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outskirtslabs%2Fdatahike-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outskirtslabs%2Fdatahike-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outskirtslabs","download_url":"https://codeload.github.com/outskirtslabs/datahike-sqlite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outskirtslabs%2Fdatahike-sqlite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276714454,"owners_count":25691398,"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-24T02:00:09.776Z","response_time":97,"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":["clojure","datahike","datalog","sqlite"],"created_at":"2025-09-24T08:13:30.109Z","updated_at":"2025-09-24T08:13:32.965Z","avatar_url":"https://github.com/outskirtslabs.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Datahike SQLite Backend\n\nThis library provides a backend for [Datahike][datahike] using [SQLite][sqlite] as the backing store, with direct native integration through [sqlite4clj][sqlite4clj].\n\n\u003e [!WARNING]\n\u003e This project is highly experimental and not production ready.\n\n## Why sqlite4clj?\n\nUnlike the [datahike-jdbc][datahike-jdbc] backend, this implementation uses [sqlite4clj][sqlite4clj] - a minimalist FFI binding to SQLite's C API using Java 22's Foreign Function Interface (Project Panama). This approach offers several advantages:\n\n- Bypasses JDBC overhead by interfacing directly with SQLite's C API through FFI for direct SQLite access.\n- SQLite's embedded nature doesn't require thread-backed connection pools like c3p0/HikariCP, eliminating that complexity.\n- Provides better performance through cached prepared statements per connection and inline caching of column reading functions.\n- Eliminates dependencies on sqlite-jdbc, c3p0, and next.jdbc for a smaller footprint.\n- Easier access to SQLite-specific features and pragmas for targeted optimizations.\n- More suitable architecture for SQLite's single-writer, multiple-reader model.\n\n## Usage\n\nInclude the library in your deps.edn:\n\n```clojure\n io.replikativ/datahike   {:mvn/version \"0.6.1601\"} ;; Use latest version\n ramblurr/datahike-sqlite {:git/url \"https://github.com/ramblurr/datahike-sqlite\"\n                           :git/sha \"c94e449be351b13c7b279d39ee3266cc22dd8f7d\"}\n```\n\n### Dependencies\n\n- The [io.replikativ/datahike dependency](https://clojars.org/io.replikativ/datahike) must be provided by your project and this backend is designed to work with Datahike 0.6.x versions.\n- [sqlite4clj][sqlite4clj] requires Java 22 or later.\n- If you use this library as a git dependency, you will need to prepare the library with `clj -X:deps prep`.\n- You must include `:jvm-opts [\"--enable-native-access=ALL-UNNAMED\"]` in your deps.edn alias.\n- When creating an executable jar file, you can avoid the need to pass this argument by adding the manifest attribute `Enable-Native-Access: ALL-UNNAMED` to your jar.\n\n### Example\n\n``` clojure\n(require\n '[datahike-sqlite.core] ;; required to pull in the multi-method implementations\n '[datahike.api :as d])\n\n(def cfg {:store {:backend :sqlite\n                  :dbname  \"foobar.sqlite\"\n                  ;; see sqlite4clj.core/init-db! for the possible options\n                  :sqlite-opts {:pool-size 4}}})\n\n(d/database-exists? cfg)\n;; =\u003e false\n\n(d/create-database cfg)\n\n(def conn (d/connect cfg))\n\n(d/transact conn [{:db/ident       :artifact\n                   :db/valueType   :db.type/string\n                   :db/cardinality :db.cardinality/one}\n                  {:db/ident       :level\n                   :db/valueType   :db.type/long\n                   :db/cardinality :db.cardinality/one}])\n\n(d/transact conn [{:name \"Mighty Teapot\" :age 20}])\n\n(d/q '[:find (pull ?e [*])\n       :in $ ?name\n       :where [?e :name ?name]]\n     @conn \"Mighty Teapot\")\n\n\n;; this will delete the table in the sqlite file,\n;; but will not delete the sqlite file itself\n(d/delete-database cfg)\n\n(d/release conn)\n```\n\n## Configuration\n\nThe value for `:store` is a configuration map. To invoke datahike-sqlite (this library) you must include `:backend :sqlite` in that map.\n\nYou must also include `:dbname`, a path to the SQLite file.\n\nYou can optionally include the key `:sqlite-opts` with an options map which will be passed to [`sqlite4clj.core/init-db!`][sqlite4clj].\n\n## Development\n\n### Testing\n\n```bash\nbb test\n```\n\n### Formatting\n\n```shell\nbb fmt\n```\n\n### Linting\n\n```shell\nbb lint\n```\n\n## License: MIT License\n\nCopyright © 2025 Casey Link \u003ccasey@outskirtslabs.com\u003e Distributed under the [MIT](https://spdx.org/licenses/MIT.html).\n\n[sqlite]: https://www.sqlite.org\n[sqlite4clj]: https://github.com/andersmurphy/sqlite4clj\n[datahike]: https://github.com/replikativ/datahike\n[datahike-jdbc]: https://github.com/replikativ/datahike-jdbc/\n[setup-docs]: https://github.com/replikativ/datahike/blob/master/doc/config.md\n[sqlite-config]: https://github.com/xerial/sqlite-jdbc/blob/639e362f97e10a55db772009d17b7e456675d37f/src/main/java/org/sqlite/SQLiteConfig.java#L382\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutskirtslabs%2Fdatahike-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutskirtslabs%2Fdatahike-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutskirtslabs%2Fdatahike-sqlite/lists"}