View Source Cozo Cheatsheet
Environment Variables
All engines except mem one will create a stored database on
filesystem. In case of sqlite a single file will be created, and a
directory will be generated with rocksdb.
The default path to store the db can be set modified by configuring
db_path environment variable. The directory used must exist,
cozo will not create it by default.
application:set_env(cozo, db_path, "/var/tmp").
{ok
, {_
, #cozo{
db_path = "/var/tmp/cozodb_JGsr7QVAREITm25Xq5dAw1lOQovHjvL9"
}
}
} = cozo:open().Stored databases are prefixed with cozodb_ by default, but this
value can be modified by modifying db_filename_prefix environment
variable.
application:set_env(cozo, db_filename_prefix, "cozodb_custom_prefix_").
{ok
, {_
, #cozo{
db_path = "/tmp/cozodb_custom_prefixf5anxr5GZ9CJRhVPR2lLMfSviW4CGUip"
}
}
} = cozo:open().mem is the default engine used, this value can be changed by
modifying engine environment variable.
application:set_env(cozo, engine, sqlite).thoas is the default JSON parser used to encode and decode JSON
objects. This value can be changed by modiying json_parser
environment variable.
application:set_env(cozo, json_parser, thoas).
thoas = cozo:json_encoder().
thoas = cozo:json_decoder().Databases can use custom options passed as JSON (or map() in this
interface). By default, no options (#{}) are passed. This can be
modified by changing sqlite_options and rocksdb_options
environment variables.
application:set_env(cozo, sqlite_options, #{ custom_option => <<>> }).
application:set_env(cozo, rocksdb_options, #{ custom_option => <<>> }).The default path to load cozo_nif.so file is set to the priv
directory linked from this project. This value can be changed by
modifying lib_path environment variable.
application:set_env(cozo, lib_path, "/usr/lib").Maintenance Commands
A list of functions have been created to help developers to deal with maintenance commands:
list_relations/1remove_relation/2remove_relations/2create_relation/3replace_relation/3put_row/3update_row/3remove_row/3ensure_row/3ensure_not_row/3list_columns/2list_indices/2explain/2describe/3get_triggers/2set_access_level/3set_access_levels/3get_running_queries/1kill/2compact/1
Examples
Test suites in test contain the full tutorial from cozodb official
documentation.