An Erlang NIF wrapper for CozoDB, a FOSS embeddable, transactional, relational-graph-vector database, with time travelling capability, perfect as the long-term memory for LLMs and AI.
-
cozodb0.7.5 on Linux and MacOS -
cozo_open_dbwithcozo:open/0andcozo:open/2. -
cozo_close_dbwithcozo:close/1 -
cozo_run_querywithcozo:run/2,cozo:run/3andcozo:run/4 -
cozo_import_relationswithcozo:import_relations/2 -
cozo_export_relationswithcozo:export_relations/2 -
cozo_backupwithcozo:backup/2 -
cozo_restorewithcozo:restore/2 -
cozo_import_from_backupwithcozo:import_backup/2
-
Create test suite for standard commands (
cozomodule)- test
cozo:open/0,cozo:open/1,cozo:open/2andcozo:open/3functions - test
cozo:run/2,cozo:run/3andcozo:run/4functions - test
cozo:close/1function
- test
-
Create test suite for maintenance commands (
cozomodule)- test
cozo:import_relations/2function - test
cozo:export_relations/2function - test
cozo:backup/2function - test
cozo:restore/2function - test
cozo:import_backup/2function
- test
-
Create interfaces, documentation and test suites for system commands (
cozomodule)-
cozo:list_relations/1 -
cozo:remove_relation/2andcozo:remove_relations/2 -
cozo:create_relation/3 -
cozo:replace_relation/3 -
cozo:put_row/3,cozo:update_row/3,cozo:remove_row/3 -
cozo:ensure_row/3andcozo:ensure_not_row/3 -
cozo:list_columns/2 -
cozo:list_indices/2 -
cozo:explain/2 -
cozo:describe/3 -
cozo:get_triggers/2,cozo:set_triggers/3,cozo:delete_triggers/2 -
cozo:set_access_level/3 -
cozo:set_access_levels/3 -
cozo:get_running_queries/1 -
cozo:kill/2 -
cozo:compact/1
-
-
Create tests suite for different engines
- test
memengine - test
sqliteengine - test
rocksdbengine
- test
-
Create test suite for
cozo_nifmodule -
Create
cozo_dbmodule to deal with strong isolation -
Specify interfaces
-
Add property based testing support
-
Add Dialyzer support
-
Create more usage example
-
Create distributed example
-
Check if
cozo_nif.cis safe
This project is using Makefile to extend the capability of
rebar3. everything can be easily done with it.
make all
# or
make deps compileA full test suite is present in test/cozo_SUITE.erl file, using the
cozodb tutorial present in the official documentation as template.
make testGenerate the project documentation.
make docOpen the documentation.
open doc/index.htmlNotes are also available in notes directory. You can exported them
in PDF, EPUB or HTML format if you have pandoc installed.
make notesOpen a shell with make
make shellIf you want to create a totally isolated database in its own process,
you can use cozo_db module.
% open a new database in memory
{ok, Pid} = cozo_db:start([]).
% run a query
{ok,#{ <<"headers">> => [<<"_0">>,<<"_1">>,<<"_2">>],
<<"next">> => null,
<<"ok">> => true,
<<"rows">> => [[1,2,3]],
<<"took">> => 0.001401927
}
} = cozo_db:run(Pid, "?[] <- [[1, 2, 3]]").
% close the database
ok = cozo_db:stop(Pid).If you want to create more than one process and you don't care about
isolation, you can use cozo module.
% open a new database in memory
{ok, Db} = cozo:open().
% run a query
{ok,#{ <<"headers">> => [<<"_0">>,<<"_1">>,<<"_2">>],
<<"next">> => null,
<<"ok">> => true,
<<"rows">> => [[1,2,3]],
<<"took">> => 0.001401927
}
} = cozo:run(Db, "?[] <- [[1, 2, 3]]").
% close the database
ok = cozo:close(Db).If you want an access to a low level interface, you can also use
cozo_nif module.
Some examples are present in examples directory like a cozo over
tcp, you can use with telnet or netcat.
c("examples/cozo_tcp.erl").
{ok, Pid} = cozo_tcp:start().nc localhost 6543
# ?[] <- [[1,2,3]]