skip to navigation
skip to content

Not Logged In

kenji 0.2.1

simple sqlite-backed graph datastore

Latest Version: 0.3.1

A simple, direct-edge, sqlite backed persistent social graph datastore similar in design to Twitter’s flockdb, built in and built for Python meant, for small apps that do not require a full blown graph database like Neo4j or FlockDB, and for apps that are interested in direct edges only.


>>> from kenji import Graph, V
>>> g = Graph(graphs=['follows'], mappings={'person':['knows']})

Let’s look at some queries we can do to the data above. Let’s see who node 1 follows and who follows node 2.

>>> assert g.exists(V(1).knows(2))
>>> assert 2 ==
>>> assert 1 ==
>>> g.relation_between('person', V(1)(2))

Like flockdb, kenji graphs cannot be traversed nor are they be optimized for traversal. I might add this feature if there is a need for it in the future. For now they are strictly adjacency lists due to the immense performance boost gained from storing them like that.

Persistence is based on an sqlite3 backend, and it also supports graph traversal on multiple edges instead of direct edges. Nodes are stored as and can only be positive integers. Currently I’m considering if I should support pluggable backends, i.e. to support Postgres, MySQL, MongoDB, etc.


To install Kenji, simply:

$ pip install kenji


  • small codebase: Only the necessities are included (which makes for a very small 48KB including tests), the rest is left up to the developer to implement/figure out on their own. This also cuts down the amount of bugs within the core codebase and allows us to reach 90-100% test coverage.
  • sqlite backed: Using an SQL backend means that performance can be easily tuned to fit your needs/usage patterns. For example you can always drop down to the SQL level using Graph.db.
  • fast and fun: Kenji’s API is optimized for developer happiness, and also quite performant. Using the expressive V object for querying, storing and representing edges it will make your life a breeze.
  • specific: Kenji aims to solve specific problems and adhere to specific use cases, and therefore the API isn’t too big. Use Kenji to store your relations between documents, and use a document store (such as tinydb) to store the documents themselves.
File Type Py Version Uploaded on Size
kenji-0.2.1.tar.gz (md5) Source 2014-07-26 6KB
  • Downloads (All Versions):
  • 12 downloads in the last day
  • 46 downloads in the last week
  • 235 downloads in the last month