Skip to main content

A pseudo NoSQL database

Project description


RunDb is not exactly a database. It is similar to TinyDB <>__ on storing files as json.

The main point of this library is to help the user on storing and loading data.


  • NoSql with tools to simulate relational
  • Table are all fully loaded when declared
  • Query are done using python
  • Data must be serializable, but no format is imposed: some data may be stored as dict, while other are mere strings some utilities functions may expect specific values, but it is recommended to only store Dict[str, Any] with string as key
  • No Opinion, let user defines hooks

.. code:: python

import RunDB
from pathlib import Path

db_path = Path("testRunDB")  # The folder containing the tables as json files

db = RunDB.Database(db_path)  # This will create the folder if it is missing, then loading all tables
User = db.table("user")  # Create or get table labeled as "user", it's file is called user.json
User["hello"] = {"name": "World"}

res = User.filter(lambda d: isinstance(d, dict) and "36" in d["name"])  # return a subtable as a dict

new = {"name": "new data"}
db["test"]["new"] = new
new.update({"option": "some text"}) # This will also update the value in the database

db.dump_all()  # Dump all tables

Nb: Database are simply Group of Table, We can register Tables from somewhere else or simply use a Table without Database object


You may want to use custom object.

.. code:: python

from import call_kwargs

db = RunDB.Database(...)

class User:
    def __init__(self, name, password, admin=False, groups=[]): = name
        self.pwd = password
        self.admin = admin
        self.groups = db.One2many("group", groups)

def dict_to_user(obj):
    return call_kwargs(User, obj)

def user_to_dict(obj):
    return {
        "password": obj.pwd,
        "admin": obj.admin,

class Group:
    def __init__(self, name, value): = name
        self.value = value
    def __repr__(self):
        return "Group {name}".format(

def dict_to_group(obj):
    return call_kwargs(Group, obj)

def group_to_dict(obj):
    return {
        "value": obj.value,

def group_default_key(obj):

    # Both parameter below should use validator if needed, as pydantic, marshmallow, schema, cerberus, ...
    serializer=user_to_dict,  # How to save an object
    deserializer=dict_to_user,  # How return an object 
    anonymous=group_default_key,  # how to retrieve the object key with Table.append method

u = User("paul", "passWord", groups=["first", "other"])
g1 = Group("first", 5)
g2 = Group("second", 9)
g3 = Group("other", 7)

db["user"][] = u




  • Abstract dump and loading
  • Define other dumps
  • improve relational
  • improve object mapping

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rundb, version 0.5
Filename, size File type Python version Upload date Hashes
Filename, size rundb-0.5-py3-none-any.whl (19.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size rundb-0.5.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page