Skip to main content

A NoSQL database built on JSONL format with LMDB indexing and WAL for durability

Project description

JSONLDB

A NoSQL database built on JSONL format with LMDB indexing and Write-Ahead Log (WAL) for durability.

Features

  • JSONL Storage - Records stored as JSON Lines
  • LMDB Indexing - Fast key-value index for lookups
  • WAL Architecture - Write-Ahead Log ensures durability
  • Compaction - Periodic compaction to merge WAL into data file
  • Secondary Indexes - Index specific fields for fast queries

Installation

pip install jsonldb

Or install from source:

pip install -e .

Quick Start

from jsonldb import Database

# Create database with indexed fields
db = Database("/path/to/db", index_fields=["email", "age"])

# Insert a record
id = db.insert({"name": "Alice", "email": "alice@example.com", "age": 30})

# Get by ID
record = db.get(id)
print(record.data)  # {'name': 'Alice', 'email': 'alice@example.com', 'age': 30}

# Query by indexed field
for r in db.query("age", 30):
    print(r.data)

# Update
db.update(id, {"age": 31})

# Delete
db.delete(id)

# Compact - rebuild data file and clear WAL
db.compact()

Architecture

data/
├── wal.jsonl    # Write-Ahead Log (all operations)
├── data.jsonl   # Compacted data records
└── index.lmdb  # LMDB index → data.jsonl offsets

Write Path

  1. Append operation to WAL
  2. Apply to data.jsonl
  3. Update index

Read Path

  1. Check index → if found, read from data.jsonl
  2. If not found, scan WAL for uncompacted records

Compaction

  • Merges data.jsonl + WAL into clean state
  • Rebuilds index
  • Clears WAL

API

Database

db = Database(path, index_fields=None)
  • path: Directory for database files
  • index_fields: List of fields to index

Methods

Method Description
insert(data) Insert a record, returns ID
get(id) Get record by ID
query(field, value) Query by indexed field
update(id, data) Update a record
delete(id) Delete a record
all() Iterate all records
count() Count all records
compact() Compact WAL into data file

Record

record.id      # Record ID
record.data    # Record data as dict
record.to_dict()  # Convert to dict

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

jsonldb-0.1.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

jsonldb-0.1.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file jsonldb-0.1.1.tar.gz.

File metadata

  • Download URL: jsonldb-0.1.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jsonldb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 161a1897f2c702c14109c1d9d8349d9d20875bbedb34e77d8e71847f2844888d
MD5 45d66960a5f7ea0aeaf0f3c73f3ea450
BLAKE2b-256 1178321e07b925fbd7bf5eb9c84b9d6e5b2b31cc5dbaf26e0e7118cb6fbcb794

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonldb-0.1.1.tar.gz:

Publisher: publish.yml on abdellatifLabr/jsonldb

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

File details

Details for the file jsonldb-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jsonldb-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jsonldb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93816e8bf7989bebce636cab726b1f6d4beb22b8300365a10c1558a0c9a23362
MD5 503ad5bed85bd2f24af839a49a190626
BLAKE2b-256 ec59bd1ae596cf5212f155b2af17a5f7b9037eb984f1a8e71da924fbc807bea5

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsonldb-0.1.1-py3-none-any.whl:

Publisher: publish.yml on abdellatifLabr/jsonldb

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