{"id":18980571,"url":"https://github.com/niamtokik/cozo","last_synced_at":"2025-04-19T19:13:07.696Z","repository":{"id":192855103,"uuid":"687171752","full_name":"niamtokik/cozo","owner":"niamtokik","description":"An interface to cozodb","archived":false,"fork":false,"pushed_at":"2023-09-29T13:31:17.000Z","size":798,"stargazers_count":7,"open_issues_count":12,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T12:05:48.365Z","etag":null,"topics":["c","cozo","cozodb","cozoscript","database","databases","datalog","db","erlang","nif","relational-databases"],"latest_commit_sha":null,"homepage":"https://github.com/niamtokik/cozo","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niamtokik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-04T19:35:31.000Z","updated_at":"2023-11-13T17:08:11.000Z","dependencies_parsed_at":"2023-09-22T16:36:46.949Z","dependency_job_id":"6f89303a-cf61-4fcb-963c-f2d3b33d8c0d","html_url":"https://github.com/niamtokik/cozo","commit_stats":null,"previous_names":["niamtokik/cozo"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niamtokik%2Fcozo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niamtokik%2Fcozo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niamtokik%2Fcozo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niamtokik%2Fcozo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niamtokik","download_url":"https://codeload.github.com/niamtokik/cozo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249239333,"owners_count":21235845,"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":["c","cozo","cozodb","cozoscript","database","databases","datalog","db","erlang","nif","relational-databases"],"created_at":"2024-11-08T16:07:09.853Z","updated_at":"2025-04-16T12:31:09.626Z","avatar_url":"https://github.com/niamtokik.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cozo\n\n![Cozo License](https://img.shields.io/github/license/niamtokik/cozo)\n![Cozo Top Language](https://img.shields.io/github/languages/top/niamtokik/cozo)\n![Cozo Workflow Status (master branch)](https://img.shields.io/github/actions/workflow/status/niamtokik/cozo/test.yaml?branch=master)\n![Cozo Last Commit](https://img.shields.io/github/last-commit/niamtokik/cozo)\n![Cozo Code Size (bytes)](https://img.shields.io/github/languages/code-size/niamtokik/cozo)\n![Cozo Repository File Count](https://img.shields.io/github/directory-file-count/niamtokik/cozo)\n![Cozo Repository Size](https://img.shields.io/github/repo-size/niamtokik/cozo)\n\nAn Erlang NIF wrapper for [CozoDB](https://www.cozodb.org), a FOSS\nembeddable, transactional, relational-graph-vector database, with time\ntravelling capability, perfect as the long-term memory for LLMs and\nAI.\n\n\n## Support\n\n - [x] `cozodb` 0.7.5 on Linux and MacOS\n - [x] `cozo_open_db` with `cozo:open/0` and `cozo:open/2`.\n - [x] `cozo_close_db` with `cozo:close/1`\n - [x] `cozo_run_query` with `cozo:run/2`, `cozo:run/3` and `cozo:run/4`\n - [x] `cozo_import_relations` with `cozo:import_relations/2`\n - [x] `cozo_export_relations` with `cozo:export_relations/2`\n - [x] `cozo_backup`  with `cozo:backup/2`\n - [x] `cozo_restore`  with `cozo:restore/2`\n - [x] `cozo_import_from_backup`  with `cozo:import_backup/2`\n\n## Todo\n\n - [x] Create test suite for standard commands (`cozo` module)\n   - [x] test `cozo:open/0`, `cozo:open/1`, `cozo:open/2` and\n         `cozo:open/3` functions\n   - [x] test `cozo:run/2`, `cozo:run/3` and `cozo:run/4` functions\n   - [x] test `cozo:close/1` function\n   \n - [ ] Create test suite for maintenance commands (`cozo` module)\n   - [x] test `cozo:import_relations/2` function\n   - [x] test `cozo:export_relations/2` function\n   - [x] test `cozo:backup/2` function\n   - [ ] test `cozo:restore/2` function\n   - [ ] test `cozo:import_backup/2` function\n   \n - [ ] Create interfaces, documentation and test suites for system\n       commands (`cozo` module)\n   - [ ] `cozo:list_relations/1`\n   - [ ] `cozo:remove_relation/2` and `cozo:remove_relations/2`\n   - [ ] `cozo:create_relation/3`\n   - [ ] `cozo:replace_relation/3`\n   - [ ] `cozo:put_row/3`, `cozo:update_row/3`, `cozo:remove_row/3`\n   - [ ] `cozo:ensure_row/3` and  `cozo:ensure_not_row/3`\n   - [ ] `cozo:list_columns/2`\n   - [ ] `cozo:list_indices/2`\n   - [ ] `cozo:explain/2`\n   - [ ] `cozo:describe/3`\n   - [ ] `cozo:get_triggers/2`, `cozo:set_triggers/3`, `cozo:delete_triggers/2`\n   - [ ] `cozo:set_access_level/3` \n   - [ ] `cozo:set_access_levels/3`\n   - [ ] `cozo:get_running_queries/1`\n   - [ ] `cozo:kill/2`\n   - [ ] `cozo:compact/1`\n \n - [x] Create tests suite for different engines\n   - [x] test `mem` engine\n   - [x] test `sqlite` engine\n   - [x] test `rocksdb` engine\n\n - [x] Create test suite for `cozo_nif` module\n\n - [x] Create `cozo_db` module to deal with strong isolation\n - [x] Specify interfaces\n - [ ] Add property based testing support\n - [x] Add Dialyzer support\n - [ ] Create more usage example\n - [ ] Create distributed example\n - [ ] Check if `cozo_nif.c` is safe\n\n## Build\n\nThis project is using `Makefile` to extend the capability of\nrebar3. everything can be easily done with it.\n\n```sh\nmake all\n# or\nmake deps compile\n```\n\n## Test\n\nA full test suite is present in `test/cozo_SUITE.erl` file, using the\ncozodb tutorial present in the official documentation as template.\n\n```sh\nmake test\n```\n\n## Documentation\n\nGenerate the project documentation.\n\n```sh\nmake doc\n```\n\nOpen the documentation.\n\n```sh\nopen doc/index.html\n```\n\nNotes are also available in `notes` directory. You can exported them\nin PDF, EPUB or HTML format if you have `pandoc` installed.\n\n```sh\nmake notes\n```\n\n## Usage\n\nOpen a shell with `make`\n\n```sh\nmake shell\n```\n\nIf you want to create a totally isolated database in its own process,\nyou can use `cozo_db` module.\n\n```erlang\n% open a new database in memory\n{ok, Pid} = cozo_db:start([]).\n\n% run a query\n{ok,#{ \u003c\u003c\"headers\"\u003e\u003e =\u003e [\u003c\u003c\"_0\"\u003e\u003e,\u003c\u003c\"_1\"\u003e\u003e,\u003c\u003c\"_2\"\u003e\u003e],\n       \u003c\u003c\"next\"\u003e\u003e =\u003e null,\n       \u003c\u003c\"ok\"\u003e\u003e =\u003e true,\n       \u003c\u003c\"rows\"\u003e\u003e =\u003e [[1,2,3]],\n       \u003c\u003c\"took\"\u003e\u003e =\u003e 0.001401927\n     }\n} = cozo_db:run(Pid, \"?[] \u003c- [[1, 2, 3]]\").\n\n% close the database\nok = cozo_db:stop(Pid).\n```\n\nIf you want to create more than one process and you don't care about\nisolation, you can use `cozo` module.\n\n```erlang\n% open a new database in memory\n{ok, Db} = cozo:open().\n\n% run a query\n{ok,#{ \u003c\u003c\"headers\"\u003e\u003e =\u003e [\u003c\u003c\"_0\"\u003e\u003e,\u003c\u003c\"_1\"\u003e\u003e,\u003c\u003c\"_2\"\u003e\u003e],\n       \u003c\u003c\"next\"\u003e\u003e =\u003e null,\n       \u003c\u003c\"ok\"\u003e\u003e =\u003e true,\n       \u003c\u003c\"rows\"\u003e\u003e =\u003e [[1,2,3]],\n       \u003c\u003c\"took\"\u003e\u003e =\u003e 0.001401927\n     }\n} = cozo:run(Db, \"?[] \u003c- [[1, 2, 3]]\").\n\n% close the database\nok = cozo:close(Db).\n```\n\nIf you want an access to a low level interface, you can also use\n`cozo_nif` module.\n\n## Examples\n\nSome examples are present in `examples` directory like a cozo over\ntcp, you can use with telnet or netcat.\n\n```erlang\nc(\"examples/cozo_tcp.erl\").\n{ok, Pid} = cozo_tcp:start().\n```\n\n```shell\nnc localhost 6543\n# ?[] \u003c- [[1,2,3]]\n```\n\n## References\n\n - [Official CozoDB Website](https://www.cozodb.org/)\n - [Official CozoDB Documentation](https://docs.cozodb.org/en/latest/)\n - [Official CozoDB Repository](https://github.com/cozodb/cozo)\n - [Erlang NIF](https://www.erlang.org/doc/tutorial/nif.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniamtokik%2Fcozo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniamtokik%2Fcozo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniamtokik%2Fcozo/lists"}