Skip to content

Mr-Dispatch/pharo-cozodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pharo-cozodb

A CozoDB wrapper for Pharo Smalltalk

Unit Tests Coverage Status

Pharo 11

CozoDB

CozoDB is

  • a blending of Relational, Graph & Vector database
  • performant, emeddable (not necessarilly embedded)
    • the C lib version / the Pharo wrappers come with (built-in) SQLite, RocksDB and memory back-ends
  • with Datalog as a query language (concise queries)
  • transactional, with time-travelling capabilities
  • https://github.com/cozodb/cozo

Tested (developed) on Win10 & Ubuntu 23.04, fully wrapping the (very minimalistic) C API. More examples / tests incoming.

Dependencies

  • NeoJSON (via Pharo Baseline)
  • CozoDB C library
    • from latest stable release https://github.com/cozodb/cozo/releases
    • choose one of the libcozo_c-<version>-<architecture>-<operating system>-<compiler>.<extension>.zip archives
      • Windows DLLs compiled by msvc are ~10M smaller compared to gnu ones
    • rename the library to libcozo_c.<extension> and stick it somewhere PharoVM will find it (ie. in the correct VM directory)

Load with:

Metacello new
  repository: 'github://Mr-Dispatch/pharo-cozodb/src';
  baseline: 'CozoDB';
  load.

Examples

A simple transient query

session := CDBSession openInMemory.
result := session runImmutableQuery: '?[column, another] <- [[4,"a"],[5,"b"],[6,"c"]]'.
(result columnNamed: #another) inspect.
session close.

Creating a relation, putting in some data and querying again

session := CDBSession openInMemory.

"Create a relation and insert some data"
session 
  runMutableQuery: ':create superclass {sub, super}';
	runMutableQuery: '?[sub, super] <- [[''UndefinedObject'', ''Object'']] :put superclass {sub, super }';
	runMutableQuery: '?[sub, super] <- [[''TestCase'', ''Object'']] :put superclass {sub, super }'.

"Query the relation (table)"	
result := self session runImmutableQuery: '?[subclass, superclass] := *superclass[subclass, superclass]'.
result inspect

esssion close.