Registry / database / mongoquery

mongoquery

JSON →
library1.4.3pypypi✓ verified 84d ago

A utility library that provides a MongoDB-like query language for querying Python collections, especially lists of dicts from JSON or YAML parsers. Current version is 1.4.3. Releases are infrequent; the last release was around 2019.

pip install mongoquery
INSTALL
IMPORT
SIG · MONGOQUERY
M
mongoquery
databasepythonv1.4.3
Install
1.6s avg
Import
12ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.010s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Query
from mongoquery import Query
import mongoquery
The main class is Query; importing the module alone requires mongoquery.Query.

Basic usage: create a Query with a MongoDB-like filter and call .match() on a list of dicts.

from mongoquery import Query items = [ {'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}, {'name': 'Charlie', 'age': 35} ] q = Query({'age': {'$gte': 30}}) result = q.match(items) print(result) # [{'name': 'Alice', 'age': 30}, {'name': 'Charlie', 'age': 35}]
Debug
Known issues
breakingVersion 1.4.0 changed how compiled regexes are supplied: they must be compiled regex objects (not strings with $regex) when using $regex operator.
fix
Use re.compile(r'pattern') directly as a value, or use string with '$regex' key in dict structure.
affects: >=1.4.0
gotchaThe library only matches against lists of dicts (or similar nested structures). It does not operate on arbitrary Python objects or ORM models.
fix
Ensure input data is a list of dicts-like structures. For objects, use __dict__ or convert to dict first.
affects: all
gotchaOperators like $elemMatch may behave unexpectedly if the array contains objects with extra keys; matching is done against each element entirely.
fix
Review MongoDB documentation for $elemMatch semantics and test with your data.
affects: all
Errors
Common errors & fixes
TypeError: 'Query' object is not iterable
Calling .match() incorrectly expects an iterable of dicts, but a single dict was passed.
fix
Wrap single dict in a list: q.match([my_dict]) or use q.match(my_dict) only if my_dict is itself a list.
AttributeError: 'str' object has no attribute 'items'
A string was passed where a dict was expected (e.g., using $regex as a value without proper operator syntax).
fix
For regex matching, use compiled regex: q = Query({'field': re.compile(r'pattern')}) or use dict: q = Query({'field': {'$regex': 'pattern'}}).
Upgrade
Version history
1.4.3latest on PyPI · released Sep 16, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
mongoquery — pip install mongoquery · libregistry