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.1.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.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymingledb-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 995ef387294eafeab4e14b13ed2bc3e1f5c0df10745f856013b1c9731c1eb00c
MD5 90ce94a22255c8dcdc315152fd065a05
BLAKE2b-256 3528eec34fa5d478e6cfe0b8e1ad5d75bd814fe6974be4ff04939f729980c549

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on mingledb/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.1-py3-none-any.whl.

File metadata

  • Download URL: pymingledb-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a2a745b97a9ab93648f701737b778fd3d7e0d3640e540a0a5011e7a3d1b82bf
MD5 37fe2ee713644fe75343cced5ed0a04a
BLAKE2b-256 a1e32124c68472feacf8e4492698d639bd0f559e0d27efc4b714ac2c346a6ac3

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on mingledb/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