Skip to main content

A lightweight, dependency-free document database for Python

Project description

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

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

pymangodb-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

pymangodb-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymangodb-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pymangodb-0.1.1.tar.gz
Algorithm Hash digest
SHA256 124ad70b77434c003abc181c5a3f9b8083123174494ff0383ac77e039484ce11
MD5 c329287483f81ef685caebd855055eae
BLAKE2b-256 10a9d0c80c6244041cb326b35c80734847a787481285bbd5346883dcd922fd8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pymangodb-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pymangodb-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ead04ab9422cf696f693bb741b6e830d72060b13d183d038f924a051a4c6b5b2
MD5 8e7378ad4b9f93f7d8350cb168bf4f9e
BLAKE2b-256 1122792507791bcf7bbe9cb2d01fe5c19bc3deb26cbd24472769b33e53a294ee

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