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.
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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
124ad70b77434c003abc181c5a3f9b8083123174494ff0383ac77e039484ce11
|
|
| MD5 |
c329287483f81ef685caebd855055eae
|
|
| BLAKE2b-256 |
10a9d0c80c6244041cb326b35c80734847a787481285bbd5346883dcd922fd8c
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ead04ab9422cf696f693bb741b6e830d72060b13d183d038f924a051a4c6b5b2
|
|
| MD5 |
8e7378ad4b9f93f7d8350cb168bf4f9e
|
|
| BLAKE2b-256 |
1122792507791bcf7bbe9cb2d01fe5c19bc3deb26cbd24472769b33e53a294ee
|