nl2data-mongodb
An optional MongoDB backend integration for nl2data-core. It combines metadata discovery and governed read-only MQL execution behind the core provider-neutral contracts.
pymongo is loaded lazily at first use. The core import boundary never loads
the MongoDB driver.
Install
pip install nl2data-mongodb
Requires Python 3.11+, nl2data-core>=0.1.0, and pymongo>=4.6,<5.
From a source checkout:
pip install -e packages/nl2data-mongodb
Public surface
from nl2data_mongodb import (
MongoAdapterConfig,
MongoMetadataDiscoverer,
MongoQueryAdapter,
)
MongoAdapterConfig— bounded discovery/execution configuration with host-injected URI references, collection/field allowlists, and result bounds.MongoMetadataDiscoverer— the coreMetadataDiscovererport implementation for MongoDB.MongoQueryAdapter— the coreQueryAdapterport implementation for read-only structured MQL.
Configuration
Configuration is credential-free; hosts inject the MongoDB URI through a resolver
or environment at runtime. MongoAdapterConfig carries only bounded,
fingerprintable settings.
from nl2data_mongodb import MongoAdapterConfig
config = MongoAdapterConfig(
uri_reference="env:NL2DATA_MONGODB_URI",
database="app",
allowed_collections={"users", "orders"},
max_collections=100,
)
Discovery
from nl2data_mongodb import MongoAdapterConfig, MongoMetadataDiscoverer
from nl2data_core.metadata.protocol import MetadataDiscoveryConfig
discoverer = MongoMetadataDiscoverer(
config=MongoAdapterConfig(
uri_reference="env:NL2DATA_MONGODB_URI",
database="app",
),
allowed_collections={"users", "orders"},
)
snapshot = await discoverer.discover(MetadataDiscoveryConfig())
Discovery returns a core MetadataSnapshot with canonical dotted paths only;
raw document values are never sampled. Dynamic paths are marked observed and
observed_incomplete because bounded sampling cannot prove a complete schema.
Query execution
from nl2data_mongodb import MongoAdapterConfig, MongoQueryAdapter
from nl2data_core.adapters.models import ValidationContext
adapter = MongoQueryAdapter(
config=MongoAdapterConfig(
uri_reference="env:NL2DATA_MONGODB_URI",
database="app",
),
allowed_collections={"users"},
)
artifact = adapter.parse('{"spec_id":"a","operation":"find","collection":"users","projection":{"name":1},"limit":10}', ValidationContext())
validated = adapter.validate(artifact, ValidationContext())
result = await adapter.execute(validated, ValidationContext())
Execution uses a read-only client, enforces pipeline/stage/operator validation, limits rows/columns/bytes, and maps every result value to the protected scalar set.
Failure classification
| Condition | Normalized result |
|---|---|
| Missing driver / unreachable service | MongoUnavailableError |
| Authorization or permission denial | MetadataUnauthorizedError |
| Lifecycle misuse (unparsed/unvalidated artifacts) | MongoAdapterError |
| Guard rejection (scope/obligation/limit) | MongoAdapterError |
| Statement/result bounds exceeded | MongoExecutionError |
| Malformed MQL / unsupported construct | MongoAdapterError |
URIs, raw BSON, native exceptions, and credentials never cross the boundary.
Compatibility
The in-core nl2data_core.adapters.mongodb module was removed. All MongoDB
integration ships from this package; import from nl2data_mongodb directly.
The core distribution no longer ships a MongoDB adapter or mongodb extra.
More documentation
Metadata
Release files for nl2data-mongodb 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nl2data_mongodb-0.1.0.tar.gz | 42.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nl2data_mongodb-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 87.8 kB
Release files / nl2data_mongodb-0.1.0.tar.gz
| Download URL | nl2data_mongodb-0.1.0.tar.gz |
|---|---|
| Size | 42.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07409e097ad291bad7f9c64954904aab875e01b685b5987be6150a3eda586006
|
|
BLAKE2b-256 checksum How to use checksums |
2ba40bca88e83018a13f5bf427bb4335d877983b568e2c4673651288b7548291
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency logRelease files / nl2data_mongodb-0.1.0-py3-none-any.whl
| Download URL | nl2data_mongodb-0.1.0-py3-none-any.whl |
|---|---|
| Size | 45.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3147dfe8b2fe323f60a0ff8dc31179738404490cdcd9092d9acaa9de41fb01c
|
|
BLAKE2b-256 checksum How to use checksums |
07efaf62f4410589fd928e9cc826db05010ed09e07707e19f5c7ffeda378f001
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.
Transparency log