Skip to main content

Lightweight file-based NoSQL engine (Python port of mingleDB). BSON + zlib, schema, query operators, auth.

Project description

pymingleDB

Lightweight file-based NoSQL engine — Python port of mingleDB. Same format as the JavaScript and gomingleDB implementations: BSON serialization, zlib compression, optional schema validation, query operators, and basic authentication.

Install (uv)

cd pymingleDB
uv sync

Or add to your project:

uv add pymingleDB

Usage

from pymingledb import MingleDB, ValidationError, UsernameExistsError, AuthFailedError

db = MingleDB("./mydb")  # or any path

# Schema (optional)
db.define_schema("users", {
    "name": {"type": "string", "required": True},
    "email": {"type": "string", "required": True, "unique": True},
    "age": {"type": "number"},
})

# CRUD
db.insert_one("users", {"name": "Alice", "email": "alice@example.com", "age": 30})
db.insert_one("users", {"name": "Bob", "email": "bob@example.com", "age": 17})

db.find_all("users")
db.find_one("users", {"email": "alice@example.com"})
db.find("users", {"age": {"$gte": 18, "$lt": 60}})
db.find("users", {"name": {"$regex": "ali", "$options": "i"}})
db.find("users", {"email": {"$in": ["alice@example.com", "bob@example.com"]}})

db.update_one("users", {"name": "Alice"}, {"age": 31})
db.delete_one("users", {"email": "bob@example.com"})

# Auth (uses internal _auth collection)
db.register_user("admin", "secure123")
db.login("admin", "secure123")
db.is_authenticated("admin")  # True
db.logout("admin")

# Reset (wipe all collections and schemas)
db.reset()

Query operators

  • $gt, $gte, $lt, $lte — numeric comparison
  • $eq, $ne — equality
  • $in, $nin — in list / not in list
  • $regex, $options — regex (e.g. "i" for case-insensitive)

You can also pass a compiled re.Pattern as a filter value for regex match.

Exceptions

  • MingleDBError — base
  • UsernameExistsError — register with existing username
  • AuthFailedError — login failed
  • ValidationError — schema validation (required, type, unique)

File format

Collections are stored as <collection>.mgdb files: header MINGLEDBv1, 4-byte meta length, JSON meta, then for each document: 4-byte length + zlib(BSON(doc)). Compatible with mingleDB (JS) and gomingleDB (Go).

Tests

uv sync --extra dev
uv run pytest tests/ -v

License

Use under the same terms as mingleDB / gomingleDB.

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

pymingledb-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

pymingledb-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file pymingledb-1.0.0.tar.gz.

File metadata

  • Download URL: pymingledb-1.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymingledb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c8ebceb4ba57621b6f67641befc5e0f7a1e902a15af31a7a3edad1827e6b6486
MD5 ece0a5691d51c1c5a1148ce71b235c03
BLAKE2b-256 31854120b1652a61cae5d0d7b8b47afdcd6fe0931e480726894f63b182035964

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymingledb-1.0.0.tar.gz:

Publisher: publish-pypi.yml on marcuwynu23/pymingleDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymingledb-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pymingledb-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymingledb-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68fae061e07c220a9ff1e23cfe32fe57b4f2c6f89bed4231f4586e515e4633fe
MD5 322c23ca52d036e20dae7a92587948e8
BLAKE2b-256 7c5d999115134b97ae35ea9eeeea1130b42297c62e6afad03402a7f178308dae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymingledb-1.0.0-py3-none-any.whl:

Publisher: publish-pypi.yml on marcuwynu23/pymingleDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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