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")  # directory -> ./mydb/database.mgdb
# db = MingleDB("./mydb/app.mgdb")  # explicit single-file 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 database file 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

All collections are stored in one .mgdb database file, compatible with mingleDB (JS) and gomingleDB (Go). Internal file layout details are intentionally abstracted from user-facing docs.

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.1.0.tar.gz (5.1 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.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pymingledb-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1eefb87ebfc51637a3ef64ada439b4120bad26ea9fa3b5703743bde44264edb4
MD5 aeb8ed45e217a05959eb01afdb2b2f4f
BLAKE2b-256 b2b4cba0619f2091294d52fc071dd6b42224235690026268bf25d908dc7b478f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymingledb-1.1.0.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.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pymingledb-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c540fb4a3bdf6e4fe7d9eb8a7dd3bf9fbfdbc6711b277c278dbef317a5affb2
MD5 83de3129de24ae555f56745fa01be896
BLAKE2b-256 fe8f5eaf8e8a42cfa7502abe0cf216b88a9bb2123253753e7b1e87c0c408f7f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymingledb-1.1.0-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