Skip to main content

Embedded JSONL DB with strict schema, in-file header (schema+taxonomies), in-memory indexes, and fast regex queries.

Project description

Embedded JSONL DB Engine

Human-readable and human-editable storage for serializable objects. A single JSONL file acts as a database with a typed schema and taxonomies stored in the header. Appends-only write model means you don't rewrite the whole file on every change. The schema exists but can evolve freely: add new fields at any time, and the database will self-adapt by materializing defaults and preserving existing data without manual migrations. For simple predicates we use a fast regex plan; otherwise we fall back to full JSON parsing. Single-writer model with explicit compaction, rolling & daily backups, and external BLOB storage.

Status: alpha (0.1.0a2). Core features implemented: file I/O, in-memory indexes, CRUD, compaction, backups, taxonomy header + migrations, external BLOBs. Fast-regex plan is integrated for simple queries; complex queries fall back to full parse.

Test status

  • Full test suite passes locally (CRUD, queries, performance, backups retention, corruption handling, schema migration, taxonomy ops, blobs GC).
  • Note on parallelism: current engine favors simplicity and deterministic ordering; regex fast-path and index build operate single-threaded to avoid GIL/IPC overhead. Parallel scan/parse across CPU cores can be added later via multiprocessing if workloads demand it.
  • Run: ./run-tests.sh
  • Reference run (on Dev machine):
    • 21 passed in ~9s
    • reopen and build indexes for 10000 records: ~0.47s
    • fast-plan query (>= 5000) matched=5000: ~0.63s
    • full-parse query (same predicate via $or) matched=5000: ~0.72s

Install

  • pip install embedded_jsonl_db_engine

Quick start

Install

  • pip install embedded_jsonl_db_engine

Minimal example (quick_start.py)

from embedded_jsonl_db_engine import Database

SCHEMA = {
    "id": {"type": "str", "mandatory": False, "index": True},
    "name": {"type": "str", "mandatory": True, "index": True},
    "age": {"type": "int", "mandatory": False, "default": 0, "index": True},
    "flags": {
        "type": "object",
        "fields": {
            "active": {"type": "bool", "mandatory": False, "default": True, "index": True},
        },
    },
    "createdAt": {"type": "datetime", "mandatory": False, "index": True},
}

db = Database(path="demo.jsonl", schema=SCHEMA, mode="+")
rec = db.new()
rec["name"] = "Alice"
rec["age"] = 33
rec.save()

loaded = db.get(rec.id)
print("Loaded:", loaded)

for r in db.find({"flags": {"active": True}, "age": {"$gte": 18}}):
    print("Adult active:", r["name"], r["age"])

Run the example

  • python examples/quick_start.py

Contributing

  • Development setup: run ./setup.sh to install dev extras, then ruff and pytest locally.
  • Roadmap: implement storage I/O, open/index build, CRUD, compaction/backups, taxonomy migrations, blobs.

What has been implemented so far

  • Low-level file I/O (FileStorage): cross-platform exclusive lock, header read/write/rewrite, append meta+data with fsync, meta scan with offsets, atomic replace.

  • Database open with progress: lock, header init if missing, base meta index rebuild, secondary/reverse index build.

  • In-memory indexes: secondary (scalar) and reverse (taxonomy) indexes; built on open and maintained on save()/delete(); prefilter in find().

  • CRUD: new() with defaults, get() (with optional meta), save() with schema validation and canonical JSON, find() with predicate evaluation + index prefilter, update(), delete() (logical).

  • Queries: field projection (fields=[...]), ordering (supports nested paths "a/b"), skip/limit; is_simple_query() helper; fast regex plan for simple scalar predicates with fallback to full json.loads.

  • Maintenance: compact_now() (garbage ratio ≥ 0.30), backup_now() (rolling and daily .gz) with progress events.

  • Taxonomies: header-only updates (rewrite_header), full migrations (rename/merge/delete detach) with progress; strict schema validation for taxonomy-backed fields.

  • BLOBs: external CAS by sha256 with put/open/gc and Database wrappers.

  • Utilities: ISO timestamps, epoch converters, canonical JSON, sha256, ULID-like ids.

    PyPI Downloads

License MIT

Project details


Download files

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

Source Distribution

embedded_jsonl_db_engine-0.1.0a7.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

embedded_jsonl_db_engine-0.1.0a7-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file embedded_jsonl_db_engine-0.1.0a7.tar.gz.

File metadata

File hashes

Hashes for embedded_jsonl_db_engine-0.1.0a7.tar.gz
Algorithm Hash digest
SHA256 a0468e359d13221c0bc81ff500ee50676c6a0407a6fbc2510512c78a94b8fc31
MD5 e339e599235557ad2d823b487b66b966
BLAKE2b-256 f4a9914732848d5522996d283ddd17892ab34d68c3da6fbae61de25ee1c56ee4

See more details on using hashes here.

Provenance

The following attestation bundles were made for embedded_jsonl_db_engine-0.1.0a7.tar.gz:

Publisher: publish.yml on mykolarudenko/embedded_jsonl_db_engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file embedded_jsonl_db_engine-0.1.0a7-py3-none-any.whl.

File metadata

File hashes

Hashes for embedded_jsonl_db_engine-0.1.0a7-py3-none-any.whl
Algorithm Hash digest
SHA256 36da3870a214c880b550ab8121bad98dc99580c3295f5efaf8b4f345d480aaa0
MD5 ab3e29f6c1bf067498268868febb6761
BLAKE2b-256 fc96ff3623b454e0a53dfd579786bbc99807849ec1b4512d99466f26b0b21eac

See more details on using hashes here.

Provenance

The following attestation bundles were made for embedded_jsonl_db_engine-0.1.0a7-py3-none-any.whl:

Publisher: publish.yml on mykolarudenko/embedded_jsonl_db_engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page