Skip to main content

MangoDB

A lightweight, thread-safe document database that stores data in a single JSON file.

PyPI - Status PyPI - Format

Features

  • Thread-safe operations with read-write locking
  • Support for concurrent reads
  • Batch operations for better performance
  • Automatic version control with backup files
  • Custom Python type serialization
  • Platform independent (Linux, Windows, MacOS)
  • No external dependencies

Installation

pip install pymangodb

Quick Start

from mangodb import MangoDB

# Initialize database
db = MangoDB("data.json")

# Insert documents
doc_id = db.insert("users", {"name": "Alice", "age": 25})

# Batch insert
doc_ids = db.batch_insert("users", [
    {"name": "Bob", "age": 30},
    {"name": "Charlie", "age": 35}
])

# Find documents
results = db.find("users", {"age": {"$gt": 30}})

# Update documents
db.update("users", {"name": "Alice"}, {"age": 26})

# Batch update
db.batch_update("users", [
    {"query": {"name": "Bob"}, "update": {"age": 31}},
    {"query": {"name": "Charlie"}, "update": {"age": 36}}
])

# Delete documents
db.delete("users", {"name": "Charlie"})

Thread Safety

All operations are thread-safe. The database uses a two-tier locking mechanism:

  • Read operations can run concurrently
  • Write operations are serialized

Version Control

Enable automatic backups before modifications:

db.version_control(True)  # Creates backup files before changes

Custom Types

Register your custom classes for serialization:

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age is age

db.register_type(Person)
db.insert("people", Person("Alice", 25))

See API.md for detailed documentation.

Notice

The codebase may contain AI slop.

License

MIT License

Metadata

Release files for pymangodb 0.1.1

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

Source distribution (sdist)

Source distribution for pymangodb 0.1.1
File Size Uploaded
pymangodb-0.1.1.tar.gz 6.8 kB Details

Built distribution (wheel)

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

Total release size: 12.8 kB

Release files / pymangodb-0.1.1.tar.gz

Download URL pymangodb-0.1.1.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
124ad70b77434c003abc181c5a3f9b8083123174494ff0383ac77e039484ce11
BLAKE2b-256 checksum
How to use checksums
10a9d0c80c6244041cb326b35c80734847a787481285bbd5346883dcd922fd8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / pymangodb-0.1.1-py3-none-any.whl

Download URL pymangodb-0.1.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ead04ab9422cf696f693bb741b6e830d72060b13d183d038f924a051a4c6b5b2
BLAKE2b-256 checksum
How to use checksums
1122792507791bcf7bbe9cb2d01fe5c19bc3deb26cbd24472769b33e53a294ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

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