Skip to content

Orfeous/MangoDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages