Skip to main content

FerrumDB — Zero-setup embedded document database for Python. No server. No config. Just open a file and go.

Project description

FerrumDB Python Bindings

PyPI PyPI Downloads Python Versions

FerrumDB is a zero-setup embedded document database for Python, powered by Rust.

  • Zero-setup — no server, no config, just open()
  • Rust-speed — AOF writes, in-memory index for O(1) reads
  • AES-256 Encrypted — optional encryption at rest
  • Native JSON — store any structured document
  • Secondary Indexing — query by JSON fields
  • TTL Support — keys auto-expire after a configurable duration
  • Built-in Dashboard — launch Ferrum Studio from your app

Installation

From PyPI (recommended)

pip install ferrumdb

From source (requires Rust toolchain + maturin)

pip install maturin
git clone https://github.com/MuhammadUsmanGM/FerrumDB.git
cd FerrumDB/ferrumdb-python
maturin develop --release

Quick Start

from ferrumdb import FerrumDB, Transaction

# Zero-setup: creates myapp.db if it doesn't exist
db = FerrumDB.open("myapp.db")

# Store any JSON-serializable value
db.set("user:1", {"name": "alice", "role": "admin", "score": 99})
db.set("user:2", {"name": "bob", "role": "user", "score": 45})

# TTL — auto-expires after 60 seconds
db.set_ex("session:abc", {"token": "xyz"}, 60)

# Read back
user = db.get("user:1")
print(user)  # {"name": "alice", "role": "admin", "score": 99}

print(db.count())  # 2
print(db.keys())   # ["user:1", "user:2"]

# Delete
db.delete("user:2")

Encryption

Open a database with AES-256-GCM encryption at rest:

db = FerrumDB.open("secure.db", encryption_key="my_super_secret_key_32_bytes_!!?")
db.set("secret", {"classified": True})

The key must be exactly 32 characters.

Secondary Indexing

Query by JSON field values in O(1) time:

db = FerrumDB.open("myapp.db")

db.set("user:1", {"name": "alice", "role": "admin"})
db.set("user:2", {"name": "bob", "role": "user"})
db.set("user:3", {"name": "charlie", "role": "admin"})

db.create_index("role")
admins = db.find("role", '"admin"')
print(admins)  # ["user:1", "user:3"]

Transactions

tx = Transaction()
tx.set("key1", {"value": 1})
tx.set_ex("cache:temp", {"data": 123}, 300)  # TTL in transactions too
tx.delete("old_key")
db.commit(tx)  # all-or-nothing

Ferrum Studio (Web Dashboard)

Launch the built-in web dashboard directly from your app:

db = FerrumDB.open("myapp.db")
db.start_studio(7474)  # http://localhost:7474

Browse keys, inspect values, set/delete entries, and view real-time metrics — no extra tools needed.

API Reference

Method Description
FerrumDB.open(path, encryption_key=None) Open/create database. Optional AES-256 encryption.
db.set(key, value) Store any JSON-serializable value
db.set_ex(key, value, ttl_seconds) Store with TTL (auto-expires)
db.get(key) Retrieve value (returns None if not found)
db.delete(key) Delete a key (returns True if existed)
db.keys() List all keys
db.count() Total number of entries
db.create_index(field) Build secondary index on JSON field
db.find(field, value) Query by indexed field (value as JSON string)
db.commit(tx) Commit an atomic transaction
db.start_studio(port=7474) Launch Ferrum Studio dashboard

Transaction

Method Description
Transaction() Create a new transaction
tx.set(key, value) Stage a SET operation
tx.set_ex(key, value, ttl_seconds) Stage a SET with TTL
tx.delete(key) Stage a DELETE operation

Limitations

  • Entire index in RAM — Best for databases <1GB
  • Single-writer only — One process per database file
  • No range queries — Only exact value matches on indexed fields
  • No nested field indexes — Only top-level JSON fields supported

See GitHub for full documentation.

License

MIT — See LICENSE for details.

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

ferrumdb-0.2.0.tar.gz (65.1 kB view details)

Uploaded Source

Built Distributions

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

ferrumdb-0.2.0-cp312-cp312-win_amd64.whl (922.4 kB view details)

Uploaded CPython 3.12Windows x86-64

ferrumdb-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ferrumdb-0.2.0-cp311-cp311-win_amd64.whl (923.5 kB view details)

Uploaded CPython 3.11Windows x86-64

ferrumdb-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ferrumdb-0.2.0-cp310-cp310-win_amd64.whl (923.6 kB view details)

Uploaded CPython 3.10Windows x86-64

ferrumdb-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ferrumdb-0.2.0-cp39-cp39-win_amd64.whl (924.0 kB view details)

Uploaded CPython 3.9Windows x86-64

ferrumdb-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ferrumdb-0.2.0-cp38-cp38-win_amd64.whl (923.9 kB view details)

Uploaded CPython 3.8Windows x86-64

ferrumdb-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file ferrumdb-0.2.0.tar.gz.

File metadata

  • Download URL: ferrumdb-0.2.0.tar.gz
  • Upload date:
  • Size: 65.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for ferrumdb-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ceaaeb86ce63529b56c6fefa1669b458c945fd407499d3270a3515d22fac72c8
MD5 c9f0e78eb56700bc1ff744e35a8b57ef
BLAKE2b-256 80f92d779993f6c2ad7616153939d91bd7ed71d766422e779ef529887f1072c4

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 07c68c195dde2f5ba89a62c9684d7cb040c963b23b6e804d1a4345b35e5763b5
MD5 540035b2585acbfa511d009236db76f1
BLAKE2b-256 8567e514401a52aa4c253abc315fa039e3cce1fb1ddc7d9d0789ff0adc22e246

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cb109236766ea92721e436a804a4a58b384b598d5fdd507e03f1d7a77dd15835
MD5 587169501e21fda9b6a56f1095a0d43a
BLAKE2b-256 f18071d23192d52e0b998f20cc1351a6e361ff667c36340a6f9c757b849cbdd9

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8acd580fdefcf311168bae1786bd53e336163e25e98e15f492549e9e185da243
MD5 5731bc0af83314934bdc752f8d8638fa
BLAKE2b-256 e013c75f03ba9accb73013fa96ed41c2b73ff806ae1d1407a624392a7f972aec

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a1b79554aa68ad81a30dbd9cc9113bcbc03df946868a8e554f723f0842b4fa6
MD5 774d4b248d7261bc5c66f14e7c5025c1
BLAKE2b-256 a05366fe7b4efb9ce161a7133c99f0a6261e4400fe2593b8ebb22761df7ef6ca

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c3828370dd37375a8897c4f11a9c6cc2f83520565b60888377b246eced9dbe5c
MD5 72f3c6b7f3f7d52be001320de1d1c670
BLAKE2b-256 7647e5757a4bc8ed0d8c07435f6ffaf7956881b4868ee59513492c2d5bc6342a

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2fba9b0124d793af343b9d64e0db54378f389f81e3837d2875e5d516e5c5ec8
MD5 bb3bb931bcacfcc0460d4e1820bad5ac
BLAKE2b-256 b65795dec7dbdda3fdbb984f23b3300b8f18d8ce5e3975fad7dd2922f6d20aef

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ferrumdb-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 924.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for ferrumdb-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6539ef414ee1e3f7b7f9c0838e734c65fd8314468b7c52a35112e3433d908560
MD5 8d16fc38f21ade1b0daa1027f879ffe8
BLAKE2b-256 3d0dd01b26f4d54e0e79145f1b9a774174c3a9df79e87d21680ec558f43f4c51

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4414a7b5c257cfe2ecdb3c8cc7083a55d987c7bcba84fcacbfafb67ae1366882
MD5 040b6057943149dd288f58a7715e6803
BLAKE2b-256 9aa063138f6106e06218ae4b248c59c22b402f52494477bad9da684e3dc8afc9

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: ferrumdb-0.2.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 923.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for ferrumdb-0.2.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 41ea2dcd4b610c1b0de7957b71c7538b209e8b31a5b050f2524a0630edaedbfa
MD5 75f13588988b46834f332be80b8d4fba
BLAKE2b-256 8ea01bb12285be4c8f8d68464891f88f9f455f22b05b87529800f35cfdf67b92

See more details on using hashes here.

File details

Details for the file ferrumdb-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ferrumdb-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ab859e3e6597ff66704c55d20bd1b28e980fcfb8c5e06111221d5de41802340
MD5 123eff6ce41237732b6c9b13124c106f
BLAKE2b-256 9937f33abf34b7b5c65a2b6041c775f90374cb12095f7e2a42d66d135b1a4d14

See more details on using hashes here.

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