Skip to main content

Experimental

MkDB is an experimental custom database engine written in python. Please use at your own risk.

MkDB

MkDB is a log-structured, partitioned NoSQL document database built entirely in Python. It provides a robust, self-healing storage engine with full-text search, numeric indexes, and dual-protocol network access — all manageable through an embedded web control panel.

Architecture Highlights

  • Rolling Log Storage Engine: Append-only storage with safe background compaction.
  • RAM Cache & Debounced Write Queue: In-memory caching and write batching for high write throughput.
  • Query Engine & Secondary Indexes: Numeric range queries and tokenized full-text inverted indexes.
  • Data Integrity: Reed-Solomon parity encoding for proactive self-healing.
  • Dual Protocols: Persistent TCP socket (with pub-sub) or standard HTTP REST.
  • Worker Pool Orchestration: Multi-process query dispatch with auto-scaling and self-healing.
  • Web Administration UI: Embedded control panel at /control — manage stores, users, schema, metrics, workers, and server settings.

Project Structure

  • mkdb/db/: Core database engine — storage primitives, RAM cache, query engine, compaction, parity.
  • mkdb/server/: TCP socket server, HTTP data-plane server, and embedded web control panel.
  • mkdb/config/: Configuration schemas for stores, memory limits, storage thresholds, and server bindings.
  • client/: The pymkdb-client package — a lightweight, stdlib-only Python SDK.

Installation

Server

pip install PyMkDB

Client (separate package)

pip install pymkdb-client

Getting Started

Starting the Server

MkDB is a CLI tool. Point it at a directory containing a config.json:

mkdb /path/to/your/db

To generate a default config.json in a new directory:

mkdb /path/to/your/db -c

Once running, the web control panel is available at http://localhost:<control_port>.


Python Client (pymkdb-client)

Basic usage

from mkdb_client import MkDBClient

# transport="socket" (default, supports pub-sub) or transport="http"
client = MkDBClient(host="127.0.0.1", port=9001, access="RW", password="mk_db")
client.connect()

# Write a record
client.data.set("products", "prod_001", {"name": "Steel Bolt", "price": 9.99})

# Insert with a server-generated ID
resp = client.data.insert("products", {"name": "Widget", "price": 4.99})
print(resp.record_id)

# Read a record
resp = client.data.get("products", "prod_001")
if resp.found:
    print(resp.data)

# Query with filters
resp = client.data.query("products", {"price": {"lte": 10.00}})
print(resp.count, resp.ids)

# Query and return full records
resp = client.data.query("products", {"name": ["bolt"]}, hydrate=True)
print(resp.records)

# Delete a record
client.data.delete("products", "prod_001")

# Subscribe to live updates (socket transport only)
client.data.on_update("products", lambda event: print("Change:", event))

client.close()

Administrative Control (MkDBController)

from mkdb_client import MkDBController

ctrl = MkDBController(host="127.0.0.1", port=8090)
ctrl.login("admin", "secret")

# Manage workers
metrics = ctrl.metrics.get("products")
print(f"Avg wait time: {metrics['avg_wait_time']}ms")

# Manually kill a worker (it will auto-respawn)
ctrl.server.kill_worker("products", 0)

# Manage users and access
ctrl.security.user.create("alice", "password")
ctrl.security.user.set_access("alice", "products", read=True, write=True)

### Error handling

```python
from mkdb_client import (
    MkDBConnectionError,
    MkDBAuthError,
    MkDBTimeoutError,
    MkDBStoreNotFoundError,
    MkDBRecordNotFoundError,
    MkDBStoreExistsError,
    MkDBQueryError,
    MkDBServerError,
)

try:
    resp = client.get("products", "prod_001")
except MkDBRecordNotFoundError:
    print("Record does not exist")
except MkDBStoreNotFoundError:
    print("Store does not exist")
except MkDBQueryError:
    print("Invalid query filter")
except MkDBAuthError:
    print("Authentication failed")
except MkDBTimeoutError:
    print("Request timed out")
except MkDBConnectionError:
    print("Could not reach server")
except MkDBServerError as e:
    print("Server error:", e)

Control-plane client (MkDBController)

MkDBController connects to the control-plane HTTP API to manage the database programmatically:

from mkdb_client import MkDBController

ctrl = MkDBController(host="127.0.0.1", port=8090)
ctrl.login(username="admin", password="secret")

# Store management
ctrl.stores.create("orders", description="Customer orders")
ctrl.stores.list()
ctrl.stores.delete("old_store")

# Server control
ctrl.server.status()
ctrl.server.stop("http")
ctrl.server.start("http")

ctrl.logout()

See the docs/ folder for the full Query Syntax reference and SDK documentation.

Metadata

Release files for PyMkDB 0.1.43

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for PyMkDB 0.1.43
File Interpreter ABI Platform
pymkdb-0.1.43-py3-none-any.whl Python 3 none any Details

Release files / pymkdb-0.1.43-py3-none-any.whl

Download URL pymkdb-0.1.43-py3-none-any.whl
Size 235.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
718460f900d64a355f44e00c2d3c76ec8b97f5a40a3b55a1b1b372354016ddce
BLAKE2b-256 checksum
How to use checksums
98ac48296214e04942901852f6e451e62e0c788d0b2f1cacc7f314796f2a8205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.1.43 This release

1 release file

0.1.42

1 release file

0.1.41

1 release file

0.1.40

1 release file

0.1.39

1 release file

0.1.38

1 release file

0.1.37

1 release file

0.1.36

1 release file

0.1.35

1 release file

0.1.34

1 release file

0.1.33

1 release file

0.1.32

1 release file

0.1.31

1 release file

0.1.30

1 release file

0.1.29

1 release file

0.1.28

1 release file

0.1.27

1 release file

0.1.26

1 release file

0.1.25

1 release file

0.1.24

1 release file

0.1.23

1 release file

0.1.22

1 release file

0.1.21

1 release file

0.1.20

1 release file

0.1.19

1 release file

0.1.18

1 release file

0.1.17

1 release file

0.1.16

1 release file

0.1.15

1 release file

0.1.14

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page