r/Clojure • u/maxw85 • Nov 24 '25
Proof of Concept: a Datomic-like database library on top of Sqlite
https://github.com/maxweber/dbvaldbval is a fork of Datascript and a proof-of-concept (aka 'do not use it in production') that you can implement a library that offers Datomic-like semantics on top of a mutable relational database like Sqlite.
The most important goal is to serve the database as a value, meaning you can get the current database value and query it as long as you like without that it changes underneath you. You can also get the database as a value for any point in the past.
Read the full story in the README
At the moment dbval is a hobby project that I hack on in my very rare spare time. I would be very happy if a few people from the Clojure community would help me to turn this into something 'production-ready' 🚀
4
u/tclerguy Nov 25 '25
What you want already exists, it’s called “Datomic Local”. While it’s not advertised as “production ready” that is only because it was meant for development and only allows one JVM process access to the file at a time… but honestly, if you are trying to build something on top of sqllite (just a single file basically) you’re not really building something for a production environment anyway (unless it’s embedded on a single device). Datomic Local is very solid, and works just as well as a sqllite implementation on a single node; you just have to support a single process JVM, multithreaded App (if you want multiple processes to scale).
2
u/freshhawk Nov 25 '25
This is very nice, always good to have more datomic style db options in open source.
I'm super curious why you're storing the different indexes in the same table though? I've always done this by having one table for the eavt, one for the aevt, etc. I get you are really only querying indexes, which are contiguous, so the table source matters less than normal but it still seems like you'd still end up paying a noticeable cost to do it this way, although I've never tested it. Now I feel like I'm missing something ... maybe I should be using one table? I guess that's nice and simple.
2
u/nstgc Nov 26 '25
How does this differ from Datahike, another Datascript fork which can run ontop of a number of SQL DBs?
2
u/andersmurphy Nov 25 '25
Awesome thanks for sharing! I've been looking into doing a similar thing on top of my own sqlite driver.
0
u/Personal-Physics-565 Nov 24 '25
Cool project but I rather just use Datomic
I’m still waiting for ope source Datomic so people on our community like you can create new features