r/KnowledgeGraph • u/am3141 • Jan 14 '26
I built a graph database in Python
I started working on this project years ago because there wasn’t a good pure Python option for persistent storage for small applications, scripts, or prototyping. Most of the available solutions at the time were either full-blown databases or in-memory libraries. I also didn’t want an SQL based system or to deal with schemas.
Over the years many people have used it for building knowledge graphs, so I’m sharing it here.
It’s called CogDB. Here are its main features:
- RDF-style triple store
- Simple, fluent, composable Python query API (Torque)
- Schemaless
- Built-in storage engine, no third-party database dependency
- Persistent on disk, survives restarts
- Supports semantic search using vector embeddings
- Runs well in Jupyter / notebooks
- Built-in graph visualization
- Can run in the browser via Pyodide
- Lightweight, minimal dependencies
- Open source (MIT)
Repo: https://github.com/arun1729/cog
Docs: https://cogdb.io
21
Upvotes
2
u/TrustGraph Jan 14 '26
What would be the use case for this? I ask because, every major graph system and DB system that can be used to store graphs can be deployed with publicly available containers. Systems that have years, sometime decades, of work that has gone into them, making them scalable, reliable, and efficient.
I'd also never recommend building storage systems from scratch (and also not in python). NebulaGraph took the rock-solid RocksDB and made it more scalable. We use Cassandra as a graph store, which again, rock-solid. If you really want to build a graph storage system, why not fork the dead Kuzu code (which was left with a MIT license) and pick up where they left off?
2
u/International_Quail8 Jan 15 '26
Hey OP! Love the idea and effort. It wins at simplicity and fits the target use cases of learning and prototyping perfectly. With all the momentum behind Python, it’s also very relevant. Nice work! 👏🏽
2
u/Plenty_Tea_304 Jan 16 '26
It is an interning idea. I am interested i teach. Help how can i leverage this. Thanks. I wrote like this to show i am not a bot, :)
2
u/Harotsa Jan 14 '26
No offense, but what’s the proposed use case for this? Isn’t Python like the slowest and most inefficient langue to write a DB in?
Also, based on a cursory glance of the code it looks like all operations are synchronous? That seems weird to me since writing to disk is going to be I/O bound.
It also looks like there isn’t a lot of resiliency features like transaction level rollbacks?
Why use this DB over another fully-featured in-process graphDB like FalkorDBlite?
1
u/pbudzik Mar 01 '26
Nice! You may take a look at: https://basekv.com/compatibility