SPOOD
Simplest Possible Object Oriented Database
Key features of SPOOD are:
- ACID compliance
- object oriented
- client-server architecture
- all in python
- human-readable database files
- SQL-like interface
SPOOD can work with multiple unrelated data sets. That data sets will be called “databases” from now on. Databases are stored in separate files in SPOOD snapshots directories. Database name is the same as name of the file where it is stored.
Database can consist of values and objects. Values are always strings. Those strings are byte-safe, so you can store any kind of data in them. Even jpg or executable files. Objects are collections of values and/or other objects. Every object and value has some “key” associated with it. Key is just another string.
Example data file ‘clients’ may look like this:
person 39cx3 {
firstname: Xxx
surname: Yyy
service s34ds {
type: something
price: 10
}
service kjj43 {
type: something else
price: 11
}
}
person j34j3 {
firstname: Zzz
surname: Aaa
service ddff4 {
type: something else
price: 11
}
}
As you see, every key has to end with “:”.
Every DML command must be run within transaction boundary.
Transaction is started with INIT command, e.g.:
INIT READS clients
That will return transaction identifier looking somewhat like this: 000023
Then you can query database like this:
IN 000023 ON 'clients' SELECT '/person';
This will return:
'39cx3','j34j3'
Those are identifiers of all ‘person’ objects in ‘clients’ database.
You can also do:
IN 000023 ON 'clients:39cx3','clients:j34j3' SELECT '/person/service/type:','/person/service/price:';
This will return:
'something','something else'|'10','11';'something else'|'11'
You can commit transaction with:
COMMIT 000023;
or abort it with:
ABORT 000023;
All returned values are prefixed with:
”+ ” if command succeeded
”- ” with problem description if command failed
COMMANDS SUMMARY:
INIT [READS listof_databases] [WRITES listof_databases] ;
initialization of transaction
specification of “read” and “write” access to data-sets is mandatory
returns: transaction_idIN transactionid ON listofobjectid [command] ;
run command inside transaction
returns: return value of command
listof_objectid is in form: ‘database:index’[,’database:index’][,…]COMMIT transaction_id;
commit transaction
returns: COMITTEDABORT transaction_id;
abort transaction
returns: ABORTEDECHO ‘some text’;
just for testing ….
returns: some textEXIT;
disconnect
returns nothing :)
commands that can be run inside transactions:
SELECT list_of_paths
list_of_paths is in form: ‘/path1’[,’/path2’][,…]
returns: list of strings looking like this: ‘string1’,’string2’,’string3’|’string4’,’string5’;’string6’|’string7’;
finished by \n
list contains values and indexes (of objects)
, splits multiple values for one path for one object,
| splits data for different paths for one object,
; splits data for different objectsCREATE ‘key’ [‘value’]
creates key:value pair in selected object
returns: CREATED, or:
if no value is given, object is created and it’s index is returnedDROP [‘key’] [‘value’]
deletes key:value pair from selected object
if no value is given all pairs with given key are dropped
if no value and no key is given, selected object is dropped
returns: DROPPEDALTER ‘key’ ‘value1’ ‘value2’
changes key:value1 pair to key:value2
returns: ALTEREDMOVE targetobjectid ‘key’
moves selected object to object specified by targetobjectid and associates it with specified key
returns: MOVED
