owoof
A glorified query-builder inspired by Datomic that uses a datalog-like format for querying and modifying information around a SQLite database.
This is a pet project and probably shouldn't be used for anything serious.
This is implemented as a rust library. It is documented, you can read the source or maybe find the documentation published on docs.rs.
There are two rust executable targets. One provides a command-line-interface (as shown below) and another can be used for importing data from a csv file.
CLI
Compile this with cargo build using --features cli --bin cli.
The CLI can be used to initialize new database files, assert/create, retract/remove, or query information.
Here are some examples:
$ echo '' \
| owoof assert
$ echo '' \
| owoof assert
$ owoof '?pet :pet/owner ?owner' \
--show '?pet :pet/name' \
--show '?owner :person/name'
$ owoof '?person :person/starship "USS Enterprise (NCC-1701-D)"' \
'?pet :pet/owner ?person' \
'?pet :pet/name ?n'
Imported from the goodbooks-10k dataset.
$ owoof '?r :rating/score 1' \
'?r :rating/book ?b' \
'?b :book/authors "Dan Brown"' \
--show '?r :rating/user' \
--show '?b :book/title' \
--limit 5
TODO/Caveats
-
Testing is not extensive at this point.
The schema should be enforced, so no deleting attributes that are in use, but I haven't done the work to verify this so there might be some surprises.
-
Performance is not super reliable.
Version 0.2 adds partial indexes over specific attributes and has helped a lot with search performance. However, there is no index on values. Some queries are impacted by this more than others, so performance is not reliable.
The difficulty currently with a values index is that SQLite's query planner will prefer it in cases where it shouldn't. It isn't a good index and should be a last-resort -- it's also huge.
-
This is not feature-rich yet, constraints ensure equality and no support for constraints over ranges or involving logical operations exist yet and honestly I haven't tested how well it will perform with the schema changes made in 0.2.
-
owoof-csv needs a way to remap ids, so instead
:rating/bookjoining with:book/idit joins to:db/id.
Internal TODOs
-
Actually address the csv import id remap above.
-
Create DontWoof off the Connection.
-
The Select borrowing Network is a bit weird. I tried to split it off but it was still weird. Not sure what to do about that. One consideration is that pushing a Select on to a Query only borrows from the network. Maybe this could be relaxed?
-
Test reference counting? Add a clean-up that removes soups with zero rc and runs pragma optimize.
-
Maybe add some sort of update thing to shorthand retract & assert?
See Also
My blog post associated with version 0.1 this software: https://froghat.ca/blag/dont-woof
License
This is licensed under Apache License, Version 2.0.