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
- Append operation to WAL
- Apply to data.jsonl
- Update index
Read Path
- Check index → if found, read from data.jsonl
- 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 filesindex_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
161a1897f2c702c14109c1d9d8349d9d20875bbedb34e77d8e71847f2844888d
|
|
| MD5 |
45d66960a5f7ea0aeaf0f3c73f3ea450
|
|
| BLAKE2b-256 |
1178321e07b925fbd7bf5eb9c84b9d6e5b2b31cc5dbaf26e0e7118cb6fbcb794
|
Provenance
The following attestation bundles were made for jsonldb-0.1.1.tar.gz:
Publisher:
publish.yml on abdellatifLabr/jsonldb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonldb-0.1.1.tar.gz -
Subject digest:
161a1897f2c702c14109c1d9d8349d9d20875bbedb34e77d8e71847f2844888d - Sigstore transparency entry: 997175752
- Sigstore integration time:
-
Permalink:
abdellatifLabr/jsonldb@19688e0442c41e63aeeb454cd8579615bf395d13 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/abdellatifLabr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@19688e0442c41e63aeeb454cd8579615bf395d13 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93816e8bf7989bebce636cab726b1f6d4beb22b8300365a10c1558a0c9a23362
|
|
| MD5 |
503ad5bed85bd2f24af839a49a190626
|
|
| BLAKE2b-256 |
ec59bd1ae596cf5212f155b2af17a5f7b9037eb984f1a8e71da924fbc807bea5
|
Provenance
The following attestation bundles were made for jsonldb-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on abdellatifLabr/jsonldb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsonldb-0.1.1-py3-none-any.whl -
Subject digest:
93816e8bf7989bebce636cab726b1f6d4beb22b8300365a10c1558a0c9a23362 - Sigstore transparency entry: 997175823
- Sigstore integration time:
-
Permalink:
abdellatifLabr/jsonldb@19688e0442c41e63aeeb454cd8579615bf395d13 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/abdellatifLabr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@19688e0442c41e63aeeb454cd8579615bf395d13 -
Trigger Event:
push
-
Statement type: