
Ask HN: What is the sqlite of graph databases? - elviejo
This question came back today:<p>What is a single file, open source, embeddable, with a query language graph database?<p>4 years ago there was a similar question: https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=10991751
======
codykochmann
I wrote a python wrapper around sqlite to turn it into a graph database a
while back. If you haven't heard of a triplicate store pattern, thats pretty
much how you do graphdbs in sql and keep things fast. Here's a link to the
project. :)

[https://github.com/CodyKochmann/graphdb](https://github.com/CodyKochmann/graphdb)

------
dgb23
Disclaimer: Not exactly what you are looking for but very close and might suit
your needs or spark your interest anyways.

I've been playing around with datahike[0] a lot recently. It is a Clojure
Datalog based DB like Datomic[1] and in fact mimics its API and behavior, but
will by default just write to a directory (not a single file last time I
checked) and (will?) support other back-ends such as PostgreSQL. Checkout the
repo for more information on the differences.

These DBs are not exactly graph DBs (like for example Neo4j) but modelling and
(recursively) querying graph data is very much a straight-forward use-case.

Schemas are attribute based rather than record/collection based, so you get
the kind of schema flexibility you are used to from graph DBs.

Another interesting fact is that these are 'immutable' or rather value
oriented by default. In simple terms: transactions are additions of facts
rather than mutations.

Datalog is the primary query language which has really interesting/nice
properties. It is worth checking out just for that fact. In Clojure these
queries are just normal Clojure data-structures. One of the Clojure linters
clj-kondo[2] even ships with static analysis for the soundness of these
queries.

[0]
[https://github.com/replikativ/datahike](https://github.com/replikativ/datahike)

[1] [https://www.datomic.com/](https://www.datomic.com/)

[2] [https://github.com/borkdude/clj-kondo](https://github.com/borkdude/clj-
kondo)

------
raizinho
After doing a ton of searching - and being extremely picky - I ended up
writing a thin two way wrapper for sqlite and networkx. The only graph
database that was easy to get started with that I felt comfortable using was
Neo4j, and it's definitely not a sqlite equivalent.

~~~
openfuture
Would you be willing to share your code?

~~~
raizinho
I was afraid someone would ask. It's a minimal proof of concept that I did in
a day for a specific use case. It's only for directed digraphs, only stores
node attributes, and has zero tests.

If you still want to poke around:
[https://github.com/gfleetwood/nxdb](https://github.com/gfleetwood/nxdb). I
just added comments and renamed some variables for clarity, so there might be
errors.

~~~
codykochmann
I would like some pointers for networkx generation for my graphdb pypi package
if you wanna share some thoughts. :)

~~~
raizinho
Sure. Would be glad to help if I can. My email is in my GitHub profile.

